触发angular.ui popover on event但是点击

时间:2015-12-09 19:53:45

标签: angularjs angular-ui-bootstrap

是否可以在事件上触发popover指令?我正在尝试寻找一个字符串字符并触发一个自定义模板,但是,我无法找到一种方法绕过它,我只看到附加到按钮的自定义属性。

1 个答案:

答案 0 :(得分:2)

您可以使用popover-is-open显示特定事件的弹出窗口。

这是一个示例,其中超时用于模拟显示弹出窗口的事件:

标记:

<div ng-controller="PopoverDemoCtrl as vm">
    Wait for 3 seconds for the event to happen...
    <div uib-popover="Read the message!"
         popover-title="Hello World!"
         popover-placement="bottom"
         id="popover"
         class="btn btn-default spaced"
         popover-is-open="vm.showPopover">
        Popover
    </div>
</div>

JavaScript的:

function PopoverDemoCtrl($timeout) {
    var popoverDemoCtrl = this;

    popoverDemoCtrl.showPopover = false;
    $timeout(function () {
        popoverDemoCtrl.showPopover = true;
    }, 3000);
}

PopoverDemoCtrl.$inject = ['$timeout'];

angular
    .module('myApp', ['ui.bootstrap'])
    .controller('PopoverDemoCtrl', PopoverDemoCtrl);

完整的小提琴:http://jsfiddle.net/masa671/gtgqof2k/