【发布时间】:2014-12-02 10:44:22
【问题描述】:
我有以下 ng-repeat 列表:
<div class="row msf-row"
ng-repeat="record in recordlist
people-popover>
<div class="col-md-1 msf-centered" ng-show="editItem == false" ng-hide="editItem">
<button class="btn btn-primary form-control msf-paxlist"
rel="popover"
data-content="<li ng-repeat='passanger in record.pax'>
{{passanger.name}}
</li>"
data-original-title="Passanger List">
{{record.pax.length}} <i class="fa fa-user"></i>
</button>
</div>
</div>
我使用指令初始化弹出框:
.directive('peoplePopover', function() {
return function(scope, element, attrs) {
element.find("button[rel=popover]").popover({ placement: 'bottom', html: 'true'});
};
})
问题是<li ng-repeat="pasanger in record.pax">{{pasanger.name}}</li>,它不会显示。
如果我使用<li ng-repeat="record.pax">{{pax}}</li>,它将显示数组,但如果我尝试使用 ng-repeat 列出数组的对象,它将不起作用。
这是数组(记录)的样子:
record in recordlist {
date : "02/12/2014"
time : "00.02.01"
car : "369"
pax: [
{
name : "Ben"
chosen : true
},
{
name : "Eric"
chosen : true
}
]
}
有什么建议吗?
【问题讨论】:
-
能否包含您要显示的数组的结构?
-
对我来说看起来不错。只是为了确认 -
recordlist是对象还是数组? -
数组,上面的代码是来自recordlist(数组)的一个对象(记录)
-
遇到同样的问题!似乎不支持数据内容中的 ng-repeat。
标签: javascript angularjs twitter-bootstrap popover