我想将一个函数传递给BootstrapUI的popover指令。该属性通常是一个字符串,但我需要进行AJAX调用以向该指令提供该属性。目前,popover将函数显示为字符串,例如“showItem(one)”而不是调用函数的结果,例如“项目是一个”。谢谢!
HTML
<li ng-repeat="item in items"
popover-placement="top"
popover-trigger="mouseenter"
uib-popover="showItem({{item.id}})">
{{item.id}}
</li>
JS
app.controller("uibController", ["$scope", function ($scope) {
$scope.items = [
{id: "one"},
{id: "two"},
{id: "three"}
];
$scope.showItem = function(item){
$http.get('url').success(function(response){
//data for popover directive
return "Item is " + item.id;
})
};
}]);
答案 0 :(得分:1)
<div ng-repeat="item in items"
popover-placement="bottom"
popover-trigger="mouseenter"
uib-popover="{{showItem(item)}}">
{{item.id}}
</div>