First, we have to learn AngularJs directives, Directives are simple special attributes in HTML. It has own set of built-in directives which offers functionality to your applications.
To check all directive list https://docs.angularjs.org/api/ng/directive
For example, I take ng-app, ng-model, ng-init and ng-bind.
First will talk about the ng-app directive, the ng-app directive is initializing the AngularJS application. To take the values of all HTML inputs (input, radio, select and textarea) we use the ng-model.
ng-bind is print the expression. we can also be written inside double braces: {{ expression }}.
AngularJS - Directives Example 1
Note: All these directives are work in inside the ng-app closed tag. you can assign ng-app directive to any tag. like <HTML>, <DIV>, <SPAN> but make sure initialize the main parent tag.
Now, We can check data initializes before page load. For this, we can use the directive ng-init. The ng-init directive initializes application data.
You have noticed that in example 1 there is "NaN", Because of the ng-bind directive. doesn't has the value when page load.
very nice! please add more examples for better learning
ReplyDelete