ng-repeat 具有特定 ID 的内部文档
ng-repeat inside document with specific ID
我有一个包含数组的文档,例如:
$scope.items = [
{
"id": 1,
"name": "Apple"
"types": [{
"color": "red"
"size": "xxl
},
{
"color: "green"
"size": "S"
}]
},
{
...
}]
而且我想显示来自 Array "types"
的所有记录,仅针对项目 ID = 1。
我试过了(没用):
table(style="width:100%")
tr(ng-repeat="type in items.types" ng-if="items.id==1")
td
p {{ type.color}}
td
p {{ type.size}}
这可以通过使用两个带过滤器的 ng-repeat
轻松实现,这将过滤掉具有 id
1 的项目,然后在 types
上执行 ng-repeat
collection.
table(style="width:100%")
tbody(ng-repeat="item in items | filter: {id: 1 }: true")
tr(ng-repeat="type in items.types")
td
p {{ type.color}}
td
p {{ type.size}}
我有一个包含数组的文档,例如:
$scope.items = [
{
"id": 1,
"name": "Apple"
"types": [{
"color": "red"
"size": "xxl
},
{
"color: "green"
"size": "S"
}]
},
{
...
}]
而且我想显示来自 Array "types"
的所有记录,仅针对项目 ID = 1。
我试过了(没用):
table(style="width:100%")
tr(ng-repeat="type in items.types" ng-if="items.id==1")
td
p {{ type.color}}
td
p {{ type.size}}
这可以通过使用两个带过滤器的 ng-repeat
轻松实现,这将过滤掉具有 id
1 的项目,然后在 types
上执行 ng-repeat
collection.
table(style="width:100%")
tbody(ng-repeat="item in items | filter: {id: 1 }: true")
tr(ng-repeat="type in items.types")
td
p {{ type.color}}
td
p {{ type.size}}