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:
- <div Ng-app="">
- Please enter: <input type="text" ng-model="name">
- <p> Result: {{name | uppercase}}</p>
- </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:
- <div Ng-app= "" ng-init="Friends = [
- {name: ' Tom ', age:16},
- {name: ' Jerry ', age:20},
- {name: ' Garfield ', age:22}] " >
- <p> Input filter:<input type="text" ng-model="name"></p>
- <ul Style="list-style-type:none">
- <li> name, age </li>
- <li ng-repeat="x in Friends | Filter:name ">
- {{x.name + ', ' + X.age}}
- </li>
- </ul>
- </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