我试图通过使用指令将jQuery模式附加到按钮。这是html:
<div id="stopLightDialog" title="Basic dialog">
<p>Text</p>
</div>
<div ng-app="summariesApp" ng-controller="singleSNPController">
<button type="button" modal-button content="stopLight">Stop Light Info</button>
这是js:
summariesApp.directive('modalButton', function () {
function link(scope, element, attrs) {
var dialogEl;
if (attr.content = "stopLight") {
dialogEl = $("#stopLightDialog");
dialogEl.dialog({ autoOpen: false, modal: true });
}
$("#" + element.id).click(function () {
dialogEl.dialog("open");
});
}
return {
link: link
};
});
对话框在屏幕上显示为常规div,单击按钮不会执行任何操作。