AngularJS Bootstrap Process

AngularJS Bootstrap Process includes from AngularJS initialization to compilation process. AngularJS initialization can be done in two ways, automatic initialization and manual initialization.

Automatic Initialization

In automatic initialization, AngularJS initializes automatically upon DOMContentLoaded event or when the angular.js script is read if at that time document.readyState is set to 'complete'. At this point Angular looks for the ng-app directive which is root of the AngularJS compilation process. If the ngApp directive is found then Angular will:

  • Load the module associated with the directive.
  • Create the application injector
  • Start compilation of DOM from ng-app directive, the root of the compilation.

Example

<!DOCTYPE html>        
<html>        
<head> <!-- www.techstrikers.com -->        
<title>Automatic Initialization</title>        
<script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>   
 <script> 
  var app = angular.module('automaticInitialization', [])            
     app.controller('autoInitController', ['$scope', function($scope) {        
       $scope.url = "www.techstrikers.com"        
     }]);        
</script>        
</head>        
<body style="background-color:#DDE4E9;" ng-app="automaticInitialization">        
  <fieldset style="background-color:#DDE4E9;">          
    <legend>AngulerJS Automatic Initialization Example</legend>          
<div ng-controller="autoInitController">        
<p style="font-family:Arial;color:red;background:steelblue;padding:3px;width:350px;">{{url}}</p>                
      </fieldset>         
</body>        
</html> 
Try Now

Manual Initialization

Sometimes you may need to manual Initialize AngularJS in order to have more control over the initialization precess. You can do that by calling angular.bootstrap() function inside angular.element(document).ready() function.

The angular.bootstrap() function takes two parameters, the document and module name injector as the second parameter to the angular.bootstrap function.

Example

<!DOCTYPE html>        
<html>        
<head>         
<title>Manual Initialization Using Bootstrap</title>        
<script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>  
 <script> 
  var app = angular.module('manualInitialization', [])            
     app.controller('manualInitController', ['$scope', function($scope) {        
       $scope.url = "www.techstrikers.com"     
     }]);    
      angular.element(document).ready(function() {  
        angular.bootstrap(document, ['manualInitialization']);  
    });        
</script>        
</head>        
<body style="background-color:#DDE4E9;">        
  <fieldset style="background-color:#DDE4E9;">          
    <legend>AngulerJS Manual Initialization Using Bootstrap Example</legend>          
<div ng-controller="manualInitController">        
<p style="font-family:Arial;color:red;background:steelblue;padding:3px;width:350px;">{{url}}</p>                
</fieldset>         
</body>        
</html> 
Try Now

See Also

AngularJS Built-in Filters
AngularJS Built-in Directives
AngularJS Expression
AngularJS Built-in Events
AngularJS Scope Methods
AngularJS Built-in Services
AngularJS Controller Inheritance
AngularJS Custom Directives


 
 
SHARE THIS IF YOU LIKE!
submit to reddit

SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.