What is the "anyPropertyKey" in an Angular filter definition?

Angular js

{{ filter_expression | filter : expression : comparator : anyPropertyKey}}

I can not understand the last argument, i.e. anyPropertyKey. Can someone please explain to me with a simple example

<div ng-init="ar=[{n:'ram1', m:1}, {n:'mah', m:1}, {n:'vij', m:3}]">
    <div ng-repeat='x in ar | filter: "1": false: propertyName'>{{x}}</div>
</div>

this is what i have tried so far. In the above code, I should write instead of the Name property.

+4
source share
3 answers

anyPropertyKeyassociated with a filter expression. Relevant part of the documentation :

($ ) (, {$: "text" }), . , . , anyPropertyKey.

, , , :

<div ng-repeat='x in ar | filter: "1": false'>{{x}}</div>

:

<div ng-repeat='x in ar | filter: {$:1}: false'>{{x}}</div>

, ($ ) 1.

anyPropertyKey $ :

<div ng-repeat='x in ar | filter: {"@":1}: false: "@"'>{{x}}</div>

@ , $ .

:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>

<body ng-app="">
<div ng-init="ar=[{n:'ram1', m:1}, {n:'mah', m:1}, {n:'vij', m:3}]">
  <div ng-repeat='x in ar | filter: "1": false'>{{x}}</div>
  <hr />
  <div ng-repeat='x in ar | filter: {$:1}: false'>{{x}}</div>
  <hr />      
  <div ng-repeat='x in ar | filter: {"@":1}: false: "@"'>{{x}}</div>
  <hr />
  </div>

</body>
Hide result
+4

comparator , false :

  • true: , , / ( "1", )

  • false: , ( , "1" )

  • function: , ,

false, , <div ng-repeat='x in ar | filter: "1">{{x}}</div>, , filter: "1": false.


, ng-repeat='x in ar | filter: {n:"1"}. "1" n .

+1

, . , - .

In HTML 
<input placeholder="Search" ng-model="searchValue" ng-blur="filterCompleteData(searchValue, completeData)" class="input-sm-modified" type="search" />

$scope.filterCompleteData = function(searchValue, completeData){
$filter('filter')(completeData, {'$':searchValue})
}

'$' , ( searchValue) , .

0

Source: https://habr.com/ru/post/1649244/


All Articles