How many ng-App attributes can be declared in in Angular JS? and under what circumstances?
As I know that ng-app is used for auto bootstrap for an Angular JS application.
How many ng-App attributes can be declared in in Angular JS? and under what circumstances?
As I know that ng-app is used for auto bootstrap for an Angular JS application.
http://docs.angularjs.org/api/ng.directive:ngApp
Only one AngularJS application can be auto-bootstrapped per HTML document. The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application. To run multiple applications in an HTML document you must manually bootstrap them using angular.bootstrap instead. AngularJS applications cannot be nested within each other.
TL; DR: you can have more than one, but only the first will be bootstrapped.
This question is similar to:
Came across very interesting virtue of ng-app directive for angularjs version 1.2.x, we can have applications bootstrapped without specifying any module name.
By using <html ng-app="">
in the HTML template & a script file that contains the controller as a function:
function TestController($scope) {
$scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
$scope.cars = ['Audi', 'BMW', 'Merc'];
}