Filter-Initial Stage

Source: Internet
Author: User

Filter filters

1) Using the ANGULARJS filter can be used to achieve the case of string conversion, currency format conversion, array filtering and so on.

usage: pipe character (|) + Filter Name .

1. Filter uppercase, lowercase convert the string to large, lowercase, as follows:

    1. <div Ng-app="">
    2. Please enter: <input type="text" ng-model="name">
    3. <p> Result: {{name | uppercase}}</p>
    4. </div>

The use of the method is very simple, try to lowercase the effect of the filter!

Filter currency, you can convert the number to currency format, refer to the above example, try it.

2). The filter filter can filter the array and select a subset from it, using "Filter: Model Name", as shown in the following example:

  1. <div Ng-app= "" ng-init="Friends = [
  2. {name: ' Tom ', age:16},
  3. {name: ' Jerry ', age:20},
  4. {name: ' Garfield ', age:22}] " >
  5. <p> Input filter:<input type="text" ng-model="name"></p>
  6. <ul Style="list-style-type:none">
  7. <li> name, age </li>
  8. <li ng-repeat="x in Friends | Filter:name ">
  9. {{x.name + ', ' + X.age}}
  10. </li>
  11. </ul>
  12. </div>

See the output, filter filter is not very strong and the use of ultra-simple to achieve a simple filtering of data, if not to use it, then we want to achieve this data filtering effect is not very troublesome (you can try how to implement).

Filter-Initial Stage

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.