AngularJS is a Javascript Framework which extends HTML with ng-directives. Below are the directives shown:
- ng-app directive defines an AngularJS application
- ng-init directive initializes AngularJS application variables
- ng-model directive binds the value of HTML controls (input, select, textarea) to application data.
- ng-bind directive binds application data to the HTML view
The following steps will be performed when executing the angularJS in the HTML Page
- Load the angularJS Framework
- Define the usage of the angularJS Application by using ng-app directive
- Usage of the initialization by using the ng-init directive
- Define the model name by using ng-model directive
- Binding of the defined model ng-bind directive
Sample Code
<!doctype html>
<html>
<head>
<script src = “https://ajax.googleapis.com/ajax/libs/angularjs/1.5.2/angular.min.js”></script>
</head>
<body ng-app = “myapp”>
<div ng-controller = “HelloController” >
<h2>Welcome {{helloTo.title}} to the world of AngularJS!</h2>
</div>
<script>
angular.module(“myapp”, [])
.controller(“HelloController”, function($scope) {
$scope.helloTo = {};
$scope.helloTo.title = “User”;
});
</script>
</body>
</html>