假设您有一个数组,该数组ul使用lifor中的每个元素和控制器上的属性进行渲染selectedIndex.在AngularJS中li使用索引添加类的最佳方法是selectedIndex什么?
我目前正在复制(手动)li代码并将类添加到其中一个li标记并使用ng-show和ng-hide仅显示li每个索引一个.
我想做的事情如下:
<div ng-controller="TestCtrl">
<div ng-repeat="(k,v) in items | filter:hasSecurityId">
{{k}} {{v.pos}}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
AngularJs部分:
function TestCtrl($scope)
{
$scope.items = {
'A2F0C7':{'secId':'12345', 'pos':'a20'},
'C8B3D1':{'pos':'b10'}
};
$scope.hasSecurityId = function(k,v)
{
return v.hasOwnProperty('secId');
}
}
Run Code Online (Sandbox Code Playgroud)
但不知何故,它向我展示了所有项目.如何过滤(键,值)?