The Filter in AngularJS
Filter is used to change, filtering data to result in another string. Below is a list of common filters commonly used in AngularJS.
- uppercase: Convert text to uppercase.
- lowercase: Convert text to lowercase.
- currency: Currency format format text.
- filter: Filter the array, the result is a substring based on the conditions provided.
- orderby: Arrange arrays based on the information provided
Uppercase filter in AngularJS
Add uppercase filter to an expression, according to the usage below, the student's name field results will be printed in all letters.
Enter last name: < input type = "text" ng - model = "sinhvien.ho" > Enter the name : < input type = "text" ng - model = "sinhvien.ten" > Print name: {{ sinhvien . hoten () | uppercase }}
Lowercase filter in AngularJS
Add a lowercase filter to an expression. Below is an example for the filter with the output being all lowercase characters.
Type : < input type = "text" ng - model = "sinhvien.ho" > Copy ten : < input type = "text" ng - model = "sinhvien.ten" > Ten transactions : {{ studentvien . hoten () | lowercase }}
Currency filter in AngularJS
Add the currency filter to an expression. Below is an example for the currency filter that returns results in currency format.
Non-standard : < input type = "text" ng - model = "sinhvien.hocphi" > hocphi : {{ sinhvien . hocphi | currency }}
Filter filter in AngularJS
To display only the required Subjects, we use tenMonHoc as a filter.
Monology : < input type = "text" ng - model = "tenMonHoc" > Mon study : < query - repeat = "printable version ten + ', diemthi:' + monhoc . diemthi }} li > ul >
Filter orderby in AngularJS
To sort Subjects by score, we use orderBy diemthi.
Mon learn :{{ monhoc . ten + ', diemthi:' + monhoc . diemthi }} li > ul >
Example AngularJS
Here is a complete example of the filters illustrated above:
Filter trong AngularJS
Ví dụ về AngularJS từ QTMng-app = "mainApp" ng-controller = "studentController" >border = "0" > Nhập tên: type = "text" ng-model = "student.firstName" > Nhập họ: type = "text" ng-model = "student.lastName" > Nhập học phí: type = "text" ng-model = "student.fees" > Nhập môn học: type = "text" ng-model = "subjectName" >
border = "0" > Tên in hoa: {{student.fullName() | uppercase}} Tên viết thường: {{student.fullName() | lowercase}} Học phí: {{student.fees | currency}} Môn học:
ng-repeat = "subject in student.subjects | filter: subjectName |orderBy:'diem'" > {{ subject.name + ', diem:' + subject.diem }}
After running the above code, you will get the following result:
According to Tutorialspoint
Previous article: What is AngularJS?
Next lesson: Create a table in AngularJS
You should read it
May be interested
- Multilingual (i18n) in AngularJSangularjs provides multi-lingual functions (i18n) with 3 types of filters, currency, date and number. we just need to combine the js corresponding to the location depending on the country. by default it will attach to the location in the web browser.
- Expression in AngularJSexpression is used to bind application data to html tags. expression is written in {{expression}}. expression has a similar way of operating as the ng-bind directive.
- Controller component in AngularJSan angularjs application works primarily based on the controller component to control the flow of data in the application.
- MVC structure in AngularJSmodel view controller or mvc is a popular call, a software design model for web-based applications.
- Create the table in AngularJStable data is often repeated in natural order. in angularjs, ng-repeat directive can be used to draw tables easily. below is an example of how to use ng-repeat to create tables.
- Scope in AngularJSscope is a special javascript object with the role of linking controllers and views. scope contains information as model data. in the controller, model data can be accessed via the $ scope object.
- Photoshop CS: Eclipse effectin the previous article, i showed you how to create a color swirl using a few effects from the filter filter. there will be many more interesting things from this filter filter that make sure
- What is a filter? How to use Filter in photography?in photography, filter means glass filters used in many different situations, such as taking photos of low-light natural conditions, or enhancing colors, ...
- What is a UF filter? Compare UF, RO and Nano water filtration technologiesthe article of tipsmake.com will help you understand what uf filter is and what uf water filtration technology has advantages and disadvantages compared to ro and nano.
- What are the functions of HEPA filter on air purifiers?on an air purifier there is an extremely important part, which is the hepa filter. what is this filter? how does the product function? to get the answer, please refer to our following article!