1. Question:What are different ways to invoke a directive? 

    Answer
    As an attribute
    <span my-directive></span>
    
    As a class
    <span class="my-directive: expression;"></span>
    
    As an element
    <my-directive></my-directive>
    
    As a comment
    <!-- directive: my-directive expression -->






    1. Report
  2. Question:What is restrict option in directive? 

    Answer
    The restrict option in angular directive, is used to specify how a directive will be invoked in your angular app i.e. as an attribute, class, element or comment.
    There are four valid options for restrict:
    
    'A' (Attribute)- <span my-directive></span> 
    'C' (Class)- <span class="my-directive:expression;"></span> 
    'E' (Element)- <my-directive></my-directive> 
    'M' (Comment)- <!-- directive: my-directive expression -->






    1. Report
  3. Question:Can you define multiple restrict options on a directive? 

    Answer
    You can also specify multiple restrict options to support more than one methods of directive invocation as an element or an attribute. Make sure all are specified in the restrict keyword as:
    restrict: 'EA'






    1. Report
  4. Question:What is auto bootstrap process in AngularJS? OR How AngularJS is initialized automatically? 

    Answer
    Angular initializes automatically upon DOMContentLoaded event or when the angular.js script is downloaded to the browser and the document.readyState is set to complete. At this point AngularJS looks for the ng-app directive which is the root of angular app compilation and tells about AngularJS part within DOM. When the ng-app directive is found then Angular will:
    1. Load the module associated with the directive.
    2. Create the application injector.
    3. Compile the DOM starting from the ng-app root element.
    
    This process is called auto-bootstrapping.
    
    Example 
    <html> 
     <body ng-app="myApp"> 
       <div ng-controller="Ctrl"> Hello {{msg}}! </div> 
    
      <script src="lib/angular.js"></script> 
     <script> 
       var app = angular.module('myApp', []); 
       app.controller('Ctrl', function ($scope) { $scope.msg = 'World'; }); 
     </script> 
    /body> 
    </html>






    1. Report
  5. Question:What is scope in AngularJS? 

    Answer
    Scope is a JavaScript object that refers to the application model. It acts as a context for evaluating angular expressions. Basically, it acts as glue between controller and view.
    
    Controller<------> $Scope <------> View
    
    Scopes are hierarchical in nature and follow the DOM structure of your AngularJS app. AngularJS has two scope objects: $rootScope and $scope.






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd