Bootstraping an angular application is as simple as making coffee for yourself.
There are two ways to bootStrap Angular Application.
- Automatic BootStrap (Coffee by Machine)
- Manual BootStrap (Handmade coffee, you can face some trouble)
Automatic BootStrap:
When DOM content is loaded , Angular looks for the ngApp directive which designates application root.
If it finds ngApp directive
a. It loads the module associated with this directive.
e.g.
- <html ng-app='myApp'>
- <head>
- <script src='angular.js'>
- </script>
- <script>
- var app = angular.module('myApp', []);
- app.controller('myController', function($scope) {
- $scope.message = 'Dear';
- });
- </script>
- </head>
- <body>
- <div ng-controller="myController">
- <p> Hi {{ message}} </p>
- </div>
b. Then, it creates the application injector.
c. Lastly, It compiles the DOM where ngApp directive as the root of the compilation.
This whole process says that Only a portion of the DOM is being treated as an Angular application.
As both Automatic and Manual process of bootStraping of an Angular application are different one. Remember to not mix these two concepts together.
These are two ways to do the same processing.
Now let's move to the Manual process of bootstraping an Angular application.
Manual Bootstrap:
There is a big difference in Automatic and manual Bootstrap.
- You do not need to attach ng-app directive with the html element.
- You call function angular.bootstrap(document,['myApp']).
Angular.bootstrap can not create module for you untill you do not make a custom module to give it as a parameter inside.- <!doctype html>
- <html>
- <body>
- <div ng-controller="myController"> Best movie: {{MovieName}}! </div>
- <script src='angular.js'>
- </script>
- <script>
- angular.module('myApp', []).controller('MyController', ['$scope', function($scope)
- {
- $scope.MovieName = 'The IRON MAN';
- }]);
- angular.element(document).ready(function()
- {
- angular.bootstrap(document, ['myApp']);
- });
- </script>
- </body>
- </html>
Before bootstraping the process you need to add controllers, directives and services etc.
Manual bootstrap comes into picture when you need more control over the initialization process. like if you want to perform an operation before
Angular compiles a page.
NOTE: You should not use ng-app directive in case of manual bootstrap of an angular application.

Ravi PatelPosted Jun 6, 2016, 12:45 AM
nice share
Deeksha PanditPosted Jun 5, 2016, 8:42 AM
Thank you
Mahesh Kumar AlankaPosted Jun 1, 2016, 7:58 AM
good one helpful
Thiruppathi RPosted May 24, 2016, 1:28 AM
Good..
Gowtham RajamanickamPosted May 24, 2016, 1:20 AM
good work
RajaPosted May 24, 2016, 12:45 AM
Good Work
Vignesh ManiPosted May 23, 2016, 3:43 PM
Good one.
Debasis SahaPosted May 23, 2016, 1:48 PM
Good One..
Deeksha PanditPosted May 23, 2016, 7:05 AM
Thanks.
Bhuvanesh MohankumarPosted May 23, 2016, 5:34 AM
Good one
Vipul MalhotraPosted May 23, 2016, 3:24 AM
nice start