ngApp directive

The ngApp directive defines the root of an AngularJS application. Applied to one of the elements, in general HTML or body, this directive is used to bootstrap the framework. We can use it without any parameter, it indicates that the application will be bootstrapped in the automatic mode, as shown in the following code:

index.html
snippet
<!doctype html>
<html ng-app>
<head>
<title>Parking</title>
<script src="angular.js"></script>
</head>
<body>
</body>
</html>

It is recommended to provide a module name, defining the entry point of the application in which other components such as controllers, services, filters, and directives can be bound.

index.html
snippet
<!doctype html>
<html ng-app="parking">
<head>
<title>[Packt] Parking</title>
<script src="angular.js"></script>
script> var parking = angular.module("parking", []);
</script>
</head>
<body>
</body>
</html>

There can be only one ngApp directive in the same HTML document that will be loaded and bootstrapped by the framework automatically. It's possible to have multiple ngApp in the same HTML as long as you manually bootstrap them.
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +