【问题标题】:not getting angular ui bootstrap popover没有得到角度的ui引导弹出窗口
【发布时间】:2015-06-26 05:43:49
【问题描述】:
我试图在悬停时在我的<a> 上获得弹出框,如自定义指令中的here 所示。但它没有让我弹出框。这里出了什么问题。检查小提琴以查看我的整个指令定义.
template: '<h1><a popover-placement="bottom" popover="sd" popover-trigger="mouseenter">{{pages}}</a></h1>',
【问题讨论】:
标签:
angularjs
angular-ui
angular-ui-bootstrap
【解决方案2】:
你只需要做两件事:
添加模块依赖,使其能够找到弹出框
为 bootstrap 添加 css 以获得更好的视觉效果
HTML:
<div ng-app="testapp">
<div ng-controller="testCtrlr">
<div mdpagination pages="pages"></div>
</div>
</div>
控制器:
var MyDirectives = angular.module('testapp', ['ui.bootstrap']);
MyDirectives.controller('testCtrlr', ['$scope', function ($scope) {
$scope.pages = 'hover me to get popover'
}]);
MyDirectives.directive("mdpagination", function () {
console.log('DIRECTIVE!');
return {
template: '<h1><a popover-placement="bottom" popover="sd" popover-trigger="mouseenter">{{pages}}</a></h1>',
replace: true,
restrict: 'A',
// scope: {pages:'@'}, //default
link: function (scope, element, attrs) {
console.dir(scope.pages);
}
}
});