我的角度最近。我有一个数据列表,这些数据在表的视图中显示。我需要在其中一列中显示数组“ availableProducts”中每个对象的“描述”属性
数据示例:
availableProducts = [
{"sending":true,"id":"8c94a40561b6d76243bea11f","cod":"123ABC","description":"Description 1","dateUpd":"2019-03-22T08:59:17.996Z","__v":0},
{"sending":false,"id":"8ca378ee413da0715b5b48d6","cod":"987ZYX","description":"Description 2","dateUpd":"2019-04-25T08:23:11.286Z","__v":0},
{"sending":false,"id":"8bc07055cb116b1698d4b1be","cod":"000AAA","description":"Description 3","dateUpd":"2019-04-24T14:18:29.378Z","__v":0},
{"sending":false,"id":"8ac16e5564169a5233db4456","cod":"111BBB","description":"Description 4","dateUpd":"2019-04-25T08:22:23.456Z","__v":0}
]
我需要搜索id,因为此值在数据的每一行中都不同,所以在我的表中该值对应于显示产品对象的id的“ invoice.product”。 为了理解这一点,我为您提供猫鼬“发票”模型的示例:
{
"id" : ObjectId("5cb5811ffb5c03579281e22f"),
"name": "string",
"number": "671782",
"contractId": "C8282",
"product": {
"id": ObjectId("8c94a40561b6d76243bea11f"),
"sending": true,
"cod":"123ABC",
"description":"Description 1",
"dateUpd":"2019-03-22T08:59:17.996Z"
},
"url": "string",
"__v" : 0
}
到目前为止,我要显示的是这个,但是它显示了所有描述,我希望您通过id查找特定的描述,该怎么办?
<td class="text-center">
<div class="badge" ng-repeat="prod in availableProducts | filter: invoice.product">{{ prod.description }}</div>
</td>
答案 0 :(得分:1)
我对猫鼬不熟悉。但是我认为这可以解决您的问题,
<td class="text-center">
<div class="badge" *ngFor="let prod of availableProducts" [hidden]="prod.id!=invoice.product">
{{ prod.description }}
</div>
</td>