How to use filters in AngularJS and angularjs
Filters are used to modify data and can be classified into expressions or using pipeline instructions. The following is a list of commonly used filters.
Lower case Filter
Add a lower-case Filter Using the MPs queue expression. Add a lower-case filter to print the Student name with lower-case letters.
Enter first name:<input type="text" ng-model="student.firstName">Enter last name: <input type="text" ng-model="student.lastName">Name in Upper Case: {{student.fullName() | lowercase}}
Currency Filter
The expression of the number returned by the coin Filter Using the MPs queue. Here, we have added a filter for printing the cost of currency format.
Enter fees: <input type="text" ng-model="student.fees">fees: {{student.fees | currency}}
Filter
To display only the required topics, we use subjectName as the filter.
Enter subject: <input type="text" ng-model="subjectName">Subject:<ul> <li ng-repeat="subject in student.subjects | filter: subjectName"> {{ subject.name + ', marks:' + subject.marks }} </li></ul>
Sort Filter
To sort topics by TAG, we use orderBy tag.
Subject:<ul> <li ng-repeat="subject in student.subjects | orderBy:'marks'"> {{ subject.name + ', marks:' + subject.marks }} </li></ul>
Example
The following example shows all the above filters.
TestAngularJS.html
Output
Open textangularjs.html in the webbrowser and see the following results: