gpt4 book ai didi

angularjs - 在html页面中显示angularjs中的数据

转载 作者:行者123 更新时间:2023-12-02 09:13:14 25 4
gpt4 key购买 nike

我正在使用 angularjs 创建项目。我在显示数据时遇到问题:

我有如下 JSON:

$scope.customerContracts =     [{
"description": null,
"latency": "1",
"linkid": "26149e91-f6c8-47fb-a10d-691e76486871",
"contracts": [{
"contractid": "26149e91-f6c8-47fb-a10d-691e76486871.2",
"duration": 7200,
"bandwidth": 300000,
"price": 0,
"contractStatus": 8,
"version": 1560,
"deletedtimestamp": 0,
"currencyID": "1",
"renewal-option": 1,
"contract-start-time": 1461918999000,
"contract-end-time": 1461926198000
}],

"tag": null,
"connections": ["49b33cd1-5722-4e8e-b40c-03c3407c5efe", "cd354769-d52a-414e-bb7c-f0e0690ddf3b"],
"type": "0",
"linkStatus": 6,
"billing-id": "5f1dd7c5-c48b-44ed-be14-cf2a8730fe27"
}]

这是我在 html 中使用的代码。我不知道哪里出错了:

<tr ng-repeat="contract in customerContracts.contracts">
<td>{{contract.contractid}}</td>
<td>{{contract.contractStatus}}</td>
<td>{{contract.bandwidth}}</td>
<td>{{contract["contract-start-time"]}}</td>
<td>{{contract["contract-end-time"]}}</td>
<td>{{contract["renewal-option"]}}</td>
<td>{{contract.price}}</td>
<td><span class="icon_delete" ng-click="deleteInformation()"></span></td>
</tr>

最佳答案

customerContracts 是一个数组,您必须先对其ng-repeat 进行操作,然后循环遍历合约。

类似于:

<div ng-repeat="contracts in customerContracts">
<...>
<tr ng-repeat="contract in contracts.contracts">
<td>{{contract.contractid}}</td>
<td>{{contract.contractStatus}}</td>
<td>{{contract.bandwidth}}</td>
<td>{{contract["contract-start-time"]}}</td>
<td>{{contract["contract-end-time"]}}</td>
<td>{{contract["renewal-option"]}}</td>
<td>{{contract.price}}</td>
<td><span class="icon_delete" ng-click="deleteInformation()"></span></td>
</tr>
<...>
</div>

关于angularjs - 在html页面中显示angularjs中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36934913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com