我已经创建了一个带AngularJS的引导Popover。我创建了一个指令,以便按规定我用正确的指令程序的任何项目可以打开显示里面一个div一个酥料饼,如从一个按钮关闭一个AngularJS Bootstrap弹出框
<i class="fa fa-user" data-content-id="popover-account" bs-popover></i>
这显示了DIV #popover-account
的内容作为酥料饼的这个图标。
我的问题是,在某些情况下,弹出窗口可能包含一个按钮,即“取消”,它应该关闭弹出窗口。我不知道如何工作的,在这里是当前的指令:
'use strict';
angular.module('designSystemApp')
.directive('bsPopover', function() {
return {
//template: '<div></div>',
restrict: 'A',
link: function postLink(scope, element, attrs) {
var $content = $('#' + attrs.contentId);
element.popover({
trigger: 'click',
placement: 'bottom',
html: true,
container: 'body',
content: function() {
return $content.removeClass('hidden');
}
});
element.on('show.bs.popover', function() {
$('[bs-popover]').popover('hide');
});
element.on('shown.bs.popover', function() {
$('#' + attrs.contentId).find('input:first').focus();
});
}
};
});
你确实有必要以处理按钮?如果它只是驳回它,你可以有按钮存在,但实际上只是点击时消除弹出? – nycynik
或者可以在点击取消按钮时将style.display设置为'隐藏'? –
弹出窗口上有一个表单:用户标识和密码,登录,取消按钮。因此,用户填写表单并单击其中一个按钮。取消只是关闭popover。我需要一个解决方案,我可以使用任何这样的弹出窗口,作为上述模块的一部分。 – Steve