如何在AngularJs中使用ng-repeat过滤(键,值)?
2022-08-30 05:20:21
我正在尝试做这样的事情:
<div ng-controller="TestCtrl">
<div ng-repeat="(k,v) in items | filter:hasSecurityId">
{{k}} {{v.pos}}
</div>
</div>
AngularJs Part:
function TestCtrl($scope)
{
$scope.items = {
'A2F0C7':{'secId':'12345', 'pos':'a20'},
'C8B3D1':{'pos':'b10'}
};
$scope.hasSecurityId = function(k,v)
{
return v.hasOwnProperty('secId');
}
}
但不知何故,它向我展示了所有物品。如何筛选(键,值)?