我有一个数组对象,我希望通过多个属性过滤该数组,并在我的html角度绑定中获取过滤后的数组对象长度,以便复选框检查/取消选中条件,如下所示:
myArray=[
{"ID":1,"StatusID":0},
{"ID":2,"StatusID":1},
{"ID":3,"StatusID":0}];
<input type="checkbox" ng-checked="myArray|filter:{ID:2}).length==1" />
my expected result like
if (myArray.ID=2 && myArray.StatusID=1).length==1
then checkbox is checked
else unchecked
答案 0 :(得分:1)
<input type="checkbox" ng-checked="(myArray|filter:{ID:2,StatusID:1}).length==1" />