- AngularJS extends HTML with ng-directives.
- AngularJS directives are HTML attributes with an ng prefix such as (ng-app, ng-model, ng-bind).
- ng-app: defines an AngularJS application.
- ng-model: binds the value of HTML controls (input, select, textarea) to application data.
- ng-bind: binds application data to the HTML view.
- ng-init: initializes AngularJS application variables.
The previous code do the following:
- AngularJS starts automatically when the web page has loaded, as it called in the html file.
- The ng-app directive tells AngularJS that the <div> element is the owner of an AngularJS application.
- The ng-model directive binds the value of the input field to the application variable fname.
- The ng-bind directive binds the innerHTML of the <span> element to the application variable fname.
Review and try it: