Ng-init,ng-controller,ng-model

Source: Internet
Author: User

1.ng-init

Used to initialize the data, as in $scope, but is useful when mated with repeat instructions:

<Divng-repeat= "Arrouter in arr"Ng-init= "Outerindex = $index">    <Divng-repeat= "Arrinner in Arrouter"Ng-init= "Innerindex = $index">         <P>{{Arrinner}}:{{outerindex}}{{innerindex}}</P>    </Div></Div>

2.ng-controller

When the callback inside the controller is the writing of an object. Such as:

1.controller (' Aaa ', [' $scope ', fnaaa]);

function Fnaaa ($scope) {
}
FnAaa.prototype.num = ' 123 ';

The use of the Ng-controller directive is to be written like this.

<div ng-controller= "fnaaa as A1" >
<div>{{a1.text}}:{{a1.show ()}}</div>
</div>

The A1 here is a Fnaaa object that is created.

3.ng-model

This command is used for bidirectional data binding, which is used in the input box.

Events that trigger data changes can be configured through Ng-model-options.

<input type= "text" ng-model= "text" ng-model-options= "{updateon: ' Blur '}" >

Ng-init,ng-controller,ng-model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.