AngularJS is a JavaScript framework that can be included in an HTML page with a <script> tag, enhancing HTML through directives and binding data to HTML elements using expressions.
AngularJS is a JavaScript framework developed in JavaScript. It is available as a JavaScript file and can be incorporated into a web page using a <script> tag.
<script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js”></script> |
AngularJS enhances HTML with ng-directives: the ng-app directive initializes an AngularJS application, the ng-model directive binds HTML control values (input, select, textarea) to application data, and the ng-bind directive links application data to the HTML view.
<!DOCTYPE html> <html> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js”></script> <body> <div ng-app=””> <p>Name: <input type=”text” ng-model=”name”></p> <p ng-bind=”name”></p> </div> </body> </html> |
Example explained:
AngularJS initializes automatically upon loading the web page, with the ng-app directive designating the <div> element as the application’s “owner.” The ng-model directive links the input field’s value to the application variable, while the ng-bind directive ties the content of the <p> element to that same variable.