Javascript 如何使用ng repeat显示数组中对象的特定属性
如何使用ng repeat显示数组中对象的特定属性。“电子邮件”字段是我要显示的内容 JSON: 控制器:Javascript 如何使用ng repeat显示数组中对象的特定属性,javascript,angularjs,Javascript,Angularjs,如何使用ng repeat显示数组中对象的特定属性。“电子邮件”字段是我要显示的内容 JSON: 控制器: myService.getEmails().then(function (emails) { if (emails && emails.length) { $scope.emailsList = emails } }) HTML: {{item}} - 假设$scope.emailsList是电子邮件的数组,按如下方式更改HTML <
myService.getEmails().then(function (emails) {
if (emails && emails.length) {
$scope.emailsList = emails
}
})
HTML:
{{item}}
-
假设$scope.emailsList
是电子邮件的数组,按如下方式更改HTML
<tr ng-repeat="item in emailsList[0].emails track by $index">
<td>
<div class="rounded-checkbox">
<input class="form-check-input" type="checkbox">
<span></span>
</div>
</td>
<td class="col-xs-12">{{ item }}</td>
<td>-</td>
</tr>
{{item}}
-
这很有效
<tr ng-repeat="item in emailsList track by $index">
<td>
<div class="rounded-checkbox">
<input class="form-check-input" type="checkbox">
<span></span>
</div>
</td>
<td class="col-xs-12">{{ item.emails[$index] }}</td>
<td>-</td>
</tr>
{{item.emails[$index]}
-
否。我只想显示电子邮件。这将导致:{“TypeId”:3,“Type”:“Listings”,“email”:[“someemail2@example.com","someemail3@example.com","someemail5@example.com]}$scope.emailsList包含什么?$scope.emailsList=[{“TypeId”:3,“键入”:“列表”,“电子邮件”:[”someemail2@example.com“someemail3@exacom“,”一些电子邮件5@example.com“]}]更新了我的答案。请现在试试,让我知道它是否有效。我想出了另一个解决办法。{{item.emails[$index]}}-所有的电子邮件都在打印吗?我怀疑你的$scope.emailsList=[{“TypeId”:3,“Type”:“Listings”,“emails”:[”someemail2@example.com“someemail3@exacom“,”一些电子邮件5@example.com“]}]@Vivz是的!所有这些都在印刷中。你的方法:也有效。
<tr ng-repeat="item in emailsList[0].emails track by $index">
<td>
<div class="rounded-checkbox">
<input class="form-check-input" type="checkbox">
<span></span>
</div>
</td>
<td class="col-xs-12">{{ item }}</td>
<td>-</td>
</tr>
<tr ng-repeat="item in emailsList track by $index">
<td>
<div class="rounded-checkbox">
<input class="form-check-input" type="checkbox">
<span></span>
</div>
</td>
<td class="col-xs-12">{{ item.emails[$index] }}</td>
<td>-</td>
</tr>