我试图让Bootstrap Popover使用AngularUI passthrough在AngularJS中处理动态绑定数据.在我的小提琴中,我无法动态显示每个办公室的办公地点和人员名单:
http://jsfiddle.net/stevenng/wmJtr/3/
解决方法
你可以这样做的一种方法就是在像
this fiddle这样的ui-options中引用office:
<div ng-repeat="office in offices"> <a href="" ui-jq="popover" ui-options="{title:office.location,content:office.people.join(',')}">Test Popover - {{office.location}}</a> </div>
另一种方法是通过将当前项目传入其中的函数生成ui-options,如this fiddle.
使用这个HTML代码段:
<div ng-repeat="office in offices"> <a href="" ui-jq="popover" ui-options="popoverOptions(office)">Test Popover - {{office.location}}</a> </div>
而这个控制器代码:
$scope.offices = [ {location:'Europe',people:['andy','gloopy']},{location:'USA',people:['shaun','teri']},{location:'Asia',people:['ryu','bison']}]; $scope.popoverOptions = function(office){ return { title: office.location,content: office.people.join(',') }; }