我有一个弹出式窗口作为自定义指令,当单击或悬停图标时打开。点击图标后,弹出窗口会粘住,如果再次单击该图标,将关闭。现在,我想通过单击其他任何位置(但弹出窗口)来关闭弹出窗口。下面是我的代码...使用outsideClick关闭自定义指令弹出框
我的自定义DIRECTIVE
(function() {
'use strict';
angular.module('frontend.core.directives')
.directive('myPopover', [
function directive() {
return {
restrict: 'E',
templateUrl: '/frontend/core/directives/my-popover/my-popover.html',
scope: {
trigger: '@',
title:'@'
},
transclude: true,
link: function (scope, elm, attrs) {
//Need to hide content first
elm.hide();
//plugin binder
$(scope.trigger).popover({
html: true,
trigger: 'hover click',
placement: 'auto',
content: function() {
return elm.html();
},
title: function() {
return scope.title;
}
});
}
};
}
]);
}());
我的HTML
<div>
<i id="touch-details" class="fa fa-info-circle"></i>
<my-popover trigger="#touch-details" my-popover-trigger="outsideClick" title="Details">
<span>
Inside of my popover
</span>
</my-popover>
</div>
请告诉我,我需要做的,以使外界点击关闭时的酥料饼。
如果你的酥料饼有某种背后叠加的,你总是可以检查该覆盖图是否已被点击。例如:'overlay.on('click',function(){myPopover.close();});'在你的指令中 –