ANGULARJS Study Summary

Source: Internet
Author: User

Two-way data binding

Data binding is probably the coolest and most practical feature of ANGULARJS. It helps you avoid writing large amounts of initial code to save development time. A typical Web application might contain 80% of the code used to process, query, and listen to the DOM. Data binding is less code and you can focus on your application.

Example one:

<input type= "text" ng-model= "user.name" placeholder= "Please enter name" >      

The contents of H1 will change with the content in input, which reduces the number of operations and makes the code more concise.

Filter (matched substring)

Used to process an array, and then filter out the elements containing a substring to return as a subarray. Can be an array of strings, or an array of objects. If it is an array of objects, you can match the value of the property. It receives a parameter that defines the matching rules for the substring. Here's an example to illustrate the use of parameters:

$scope. Childrenarray = [

{name: ' Kimi ', Age:3},

{name: ' Cindy ', Age:4},

{name: ' Anglar ', age:4},

{name: ' Shitou ', age:6},

{name: ' Tiantian ', age:5}

];

$scope. Func = function (e) {return e.age>4;} {{Childrenarray | filter: ' A '}}//Match attribute value contains a

{{Childrenarray | filter:4}}//Match attribute value contains 4

{{Childrenarray | filter: {name: ' I '}}}//parameter is an object that matches the name attribute containing I

{{Childrenarray | filter:func}}//parameter is a function that specifies the return age>4 of the

Note: Filter ":" After the parameters are written, you must add a space symbol, or you will get an error.

ANGULARJS Study Summary

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.