在 AngularJS 中,我想显示一个计数器,显示以下每个组的“完成/所有”任务,即在这种情况下:
food: 1/2
hygienics: 0/1
任务清单:
$tasks = [
{
title: "buy bacon",
group: "food",
done: "true",
},
{
title: "buy tuna",
group: "food",
done: "false",
},
{
title: "buy toothpaste",
group: "hygienics",
done: "false",
},
];
每当我将任务的“完成”设置为“真”时,计数器应该会自动更新。所以真的,我正在寻找一个很好的过滤表达式,如下所示(但使用“完成”):
Food: {{ ( tasks | filter: {group:'food'} ).length }}
我怎样才能在其中包含“完成”?