作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Angular JS
{{ filter_expression | filter : expression : comparator : anyPropertyKey}}
<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>
最佳答案
anyPropertyKey
与过滤器的表达有关。 documentation的相关部分是:
A special property name ($ by default) can be used (e.g. as in {$: "text"}) to accept a match against any property of the object or its nested object properties. That's equivalent to the simple substring match with a string as described above. The special property name can be overwritten, using the anyPropertyKey parameter.
<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>
关于angularjs - Angular 过滤器定义中的 'anyPropertyKey' 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38605558/
Angular JS {{ filter_expression | filter : expression : comparator : anyPropertyKey}} 我无法理解最后一个参数,即
我是一名优秀的程序员,十分优秀!