Angular.js in filter Filter and custom filter Filter instance detailed

This article mainly introduces you the relevant content of the Angular.js filter Filter and custom filter Filter, share it out for your reference to learn, let’s take a look at the details:

, AngularJS Filter Filter:
Uppercase | LowerCase: Calculation Conversion Filter

    JSON: JSON Format Filter
  • Date: Date Filtering
  • Number: Digital Format Filter
  • Currency: Currency Format Filtration
  • FILTER: Find
  • Limitto: String Object Intercept
  • ORDERBY: Object Sort
Angular Foundation
     Converting strings to case:    Name {{person.lastname | Uppercase}}   
{{Person.lastname | LowerCase}}

Quantity:
Price:

Total price = {{(Quantity * Price) Currency}}

{250 | currency: "RMB ¥"}}

Sort by the alphabetical order in the country:

{{x.Name + ',' + x.country}}

{{JSONText | JSON}}

{{1288323623006 | Date: 'YYYY-MM-DD HH: mm: ss'}}

  • { {1.2345678 | Number: 1}}
{{"I love tank" | limitedto: 6}} {{"i love tank" | limitedto: -6}}
{{[{"AGE": 20, "ID": 10, "Name": "iPhone"}, {"agn": 12, "ID": 11, "Name": "sunm xing"}, {" AGE ": 44," ID ": 12," name ":" TEST ABC "}] | Orderby: 'ID': true}} {{[{" age ": 20," id " : 10, "Name": "iPhone"}, {"age": 12, "ID": 11, "name": "sunm xing"}, {"age": 44, "id": 12, "name": ":" TEST ABC "}] | Orderby: 'id'}}
Press the entered letter display object:

Enter filter:

{({{(x.Name | Uppercase) + ',' + x.country}}

Name Filter:

{{(x.Name | Uppercase) + ',' + X.Country}}

{{[{"AGE": 20, "ID": 10, "name": "iPhone"}, {"Id": 11, "name": "sunm"}, {"age": 44, "id": 12, "name": "TEST ABC"}] | filter: {'Name': 'sunm'}}}

VAR myApp = angular.Module ('myapp ", []); myapp.controller (' UppercaseController) ', Function {$ Scope.Person = {FIRSTNAME: "John", LastName: "doe"};}; myapp.controller (' LowerCaseController ', Function ($ scope) {$ scope.person = { Firstname: "john", lastname: "doe"};}; myapp.controller ('costcontroller', function ($ scope) {$Scope.quantity = 1; $ scope.price = 9.99;}; MyApp.controller ('namescontroller', function ($ scope) {$ scope.names = [{name: 'jani', country: 'norway'}, {Name: 'Hege', Country: 'Sweden'}, {Name: 'Kai', Country: 'DENMARK'}]; $ Scope.jsontext = {Foo: "Bar", Baz: 23};}; myApp .controller ('namesfiltercontroller ", function ($ scope) {$ scope.names = [{name:' jani ', country:' norway '}, {name:' hege ', country:' sweden '}, {name: 'Kai', country: 'DENMARK'}];};

Angular Foundation Angular.Js中过滤器filter与自定义过滤器filter实例详解

{{ufirstname}}

{cprice}}

 var myapp = angular.module ('myApp', []); MyApp.Controller ('firstctrl', function ($ scope, $ filter) {$ scope.firstname = "zhangsan"; $ scope.ufirstname = $ filter ('uppercase') ($ PERCASE ') ($ UPPERCASE') Scope.firstname); $ scope.price = "121212"; $ scope.cprice = $ filter ('currency') ($ scope.price, 'RMB ¥');})     Third, AngularJS Custom Filter Filter     


{{Welcome | Replacehello}} {{Welcome | Replacehello: 3: 5}} { {Welcome | RJS}}
VAR myApp = angular.Module (‘myapp “, [‘ myapp.filter ‘]); MyApp.controller (‘firstctrl’, function ($ scope) {$ scope.welcome = “Hello AngularJS”;}; // Custom Filter MyApp.Filter (‘ReplaceHello’, function () {RETurn Function (INPUT, N1, N2) {Console.log (Input); console.log (n1); console.log (n2); return input.replace (/ hello /, ‘Hello’);}})

VAR AppFilter = angular.Module (‘myapp.filter’, []); / / Custom Filter AppFilter.Filter (‘RJS’, Function () {Return Function (INPUT, N1, N2) {Console.log (Input); console.log (n1); console.log (n2); return input .replace (/ JS /, ‘JavaScript’);}});
     Summary    The above is the full content of this article. I hope this paper will bring certain help to everyone's learning or work. If you have any questions, you can leave a message to exchange, thank you for your support of Tumi Cloud.                      
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment