How to use filters in AngularJS and angularjs

Source: Internet
Author: User

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:

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.