🔰 Introduction to the ng-app Directive
Learn how AngularJS applications begin with the powerful ng-app directive.
ng-app is the foundational directive in AngularJS. It tells AngularJS where the application starts and bootstraps the framework in that part of the HTML.
📌 Purpose of ng-app
- It defines the root element of your AngularJS application.
- Automatically bootstraps (initializes) the app when the web page is loaded.
- It can take a module name as a value or be left empty for default behavior.
🛠 Usage Example
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.3/angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
</script>
</head>
<body>
<h2>AngularJS Application Started</h2>
</body>
</html>
💡 Notes:
- Only one
ng-appdirective should be present in a single HTML document. - You can place
ng-appon the<html>,<body>, or any container element. - If no module name is provided, Angular uses the default module.
ng-app to define the scope of your AngularJS app and start it cleanly.


