Object: A pattern object can be used to filter specific properties on objects contained by array. For example {name:"M", phone:"1"} predicate will return an array of itemsms whichnty name" property phone containing "1".
<li ng-repeat="phone in phones|filter:{name:query}">
2.可以使用comparator:
Comparator which is used in determining if the expected value (from the filter expression) and actual value (from the object in the array) should be considered a match. function(actual, expect ): match.
function(actual, expect. and the predicate value to compare and should return true if both values should be considered equal.
根據官方文件的描述,有幾種方式來實現:
{{ filter_expression | filter : expression : comparator}}
1.如Guox給出的方法,使用expression:
Object: A pattern object can be used to filter specific properties on objects contained by array. For example {name:"M", phone:"1"} predicate will return an array of itemsms whichnty name" property phone containing "1".
作為Object使用,用於過濾數組元素的指定屬性,如expression = {name:"M", phone:"1"} ,那麼將會過濾出數組中name包含'M'且phone包含'1'的元素。
故使用以下方法即可
2.可以使用comparator:
Comparator which is used in determining if the expected value (from the filter expression) and actual value (from the object in the array) should be considered a match.
function(actual, expect. and the predicate value to compare and should return true if both values should be considered equal.function(actual, expect ): match.
太感謝二位了,謝謝