Filter is a very useful interface for filtering data, such as searching by a field, formatting data, and so on. The following is a brief introduction to its usage.
Angularjs Filter Interface, | is the filter separator, parameters: delimited;
Currency, format number, monetization, the default is converted to USD param (number,symbol), the return value will be 3 digits per comma
<inputtype= "Number"Ng-model= "Amount"/><P>Default USD: {{amount|currency}}</P><P>RMB: {{amount|currency: ' ¥ '}}</P><P>Null: {{amount|currency: '}}</P>
Results:
Date: Formatted time, param (date| Date,number,string,format) Filter: Filter Array,param (string|object|function, second parameter not clear) JSON: Converts an object into a JSON-like string Li Mitto: Limits the length of a string or array, if the argument is positive (positive), starts with beginning, and if a negative number (negative) begins with end lowercase: lowercase uppercase: Uppercase number: The number of decimal points, the default is 3 bits, the return value will be the number of every 3 digits plus a comma-by-order: the array to sort, param (string|function|array,reverse); The basic usage of custom filter is the following example:
varModuleName = Angular.module (' modulename '), []);//filtering on StringsModulename.filter (' FilterName ',function() { return function(data) {//Do something to change the data value,but dont the data type. returndata; }})//filtering on the arrayModulename.filter (' Plus15 ',function() { return function(Orginalarr) {vararr = []; Angular.foeach (function(value, key) {if(Value >= 15) {Arr.push (value); } }) returnarr; }})
HTML use:
<ng-repeat= "value in Historydata | plus15"> <Li >{{value.day|filtername}}:{{value.temp}}</li></ ul>