我想将一个函数传递给 BootstrapUI 的 popover 指令。该属性通常是一个字符串,但我需要进行 AJAX 调用以将属性提供给指令。目前,弹出框将函数显示为字符串,例如“showItem(one)”,而不是调用函数的结果,例如“Item is 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;
})
};
}]);