【发布时间】:2016-12-29 17:28:57
【问题描述】:
我想知道在受到 ng-if 和 ng-show 约束后显示的 可见 元素的数量。这是一个简化的例子:
$scope.fruits = [
{ name: 'apple', shape: 'round', color: 'red' },
{ name: 'stop sign', shape: 'pointy', color: 'red' },
{ name: 'orange', shape: 'round', color: 'orange' },
{ name: 'tomato', shape: 'round', color: 'red'}
];
<ul>
<li ng-repeat="fruit in fruits" ng-if="fruit.color=='red'" ng-show="fruit.shape=='round'">{{fruit.name}}</li>
</ul>
有没有办法计算结果显示的项目数?
【问题讨论】:
-
你的意思是结果项的数量??
-
是的。感谢您的关注,但我能够弄清楚:)
标签: angularjs angularjs-ng-repeat ng-show