【发布时间】:2016-07-27 23:51:02
【问题描述】:
我要做的是创建一个可以根据嵌套在 JSON 对象数组中的类别进行过滤的概览。
我要创建概览的项目的 JSON 如下所示:
{
id: 1,
title: "title",
content: "content",
categories: [{
title: "cat1",
descripton: "desc"
},
{
title: "cat2",
descripton: "desc"
}]
},
{
id: 2,
title: "title",
content: "content",
categories: [{
title: "cat3",
descripton: "desc"
},
{
title: "cat4",
descripton: "desc"
}]
}
HTML 看起来像这样:
<select ng-model="catselect">
<option>cat1</option>
<option>cat2</option>
<option>cat3</option>
<option>cat4</option>
</select>
<ul>
<li ng-repeat="item in array | filter: {ARRAY OF CATEGORIES: catselect}">
</li>
</ul>
目前我不知道如何让它工作。 (我认为)最明显的解决方案应该是 filter: {categories.title: catselect} 之类的东西,但显然不是。据我所知,Stackoverflow 上没有其他问题可以解决这个问题。我很想看看是否有人可以帮助我。
【问题讨论】: