这是我的 json(每个对象可以分配给多个类别):
[
{ "title" : "titel1",
"description" : "description1",
"data": {
"categoryList" : [
{ "categoryName" : "category1" }
]
}
},
{ "title" : "titel2",
"description" : "description2",
"data": {
"categoryList" : [
{ "categoryName" : "category1" }
]
}
},
{ "title" : "titel3",
"description" : "description3",
"data": {
"categoryList" : [
{ "categoryName" : "category2" }
]
}
},
... and so on
]
div 标签显示每个类别的内容。当没有内容分配给某个类别时,我想显示消息“没有可用的内容”。不确定像 ng-show="!content."this category" .length" 这样的东西是否可以工作。
<!-- category 1 -->
<div>
<ul>
<li ng-repeat="item in content | filter:{'data':'category1'}">
{{item.title}} - {{item.description}}
</li>
<li ng-show="?????">No content available</li>
</ul>
</div>
<!-- category 2 -->
<div>
<ul>
<li ng-repeat="item in content | filter:{'data':'category2'}">
{{item.title}} - {{item.description}}
</li>
<li ng-show="?????">No content available</li>
</ul>
</div>
...