Ng-App-1

 

Ng-App is a directive that is basically bootstrap the angularjs application and this will be placed at the top root element of the tag like

and in js, Here is how we define the appExample module: var app = angular.module("appExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.a = 5; $scope.b = 10; }]);
 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body> <div class="container"> <div ng-app="appExample"><br /> <b>Inside ng-app directive.</b> <hr /> <div ng-controller="ExampleController"> I can add: {{a}} + {{b}} = {{ a+b }} </div> <div ng-controller="ExampleController"> Name: <input ng-model="name"><br /> Hello, {{name}}! </div> </div> <hr /> <b>Out of ng-App</b> <div ng-controller="ExampleController"> I can't add: {{a}} + {{b}} = {{ a+b }} </div> </div> <script> var app = angular.module("appExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.a = 5; $scope.b = 10; }]); </script> </body> </html>
Output