我有以下代码:
angular.module('myApp').controller('modalClickItemController', function ($scope, $dialog) {
$scope.openDialog = function(opts){
console.debug('bar');
var d = $dialog.dialog(opts);
d.open().then(function(result){
console.debug('foobarbazz');
});
}
});
这在如下的指令中使用:
angular.module('myApp')
.directive('modalClickItem', function () {
return {
restrict: 'A',
controller: 'modalClickItemController',
link: function postLink(scope, el, attr){
scope.objectId = attr.objectId;
scope.objectType = attr.objectType
scope.opts = {
backdrop: true,
keyboard: true,
backdropClick: true,
template: "<div class='modal-header'>Hi!!!</div><div class='modal-body'>Buy!!!</div>",
// templateUrl: 'views/'+scope.objectType+'_modal.html',
controller: 'modalCtrl'
}
el.on('click', function(){
scope.openDialog(scope.opts);
});
}
};
});
此代码打印条形图,但它从不打印foobarbazz。如果我将调试粘贴到角度引导程序中,它将进入open方法,并返回promise,但从不打开对话框。
http://plnkr.co/edit/tNokVEbRds78tBaVZtLH?p=preview
为什么?
答案 0 :(得分:0)
我使用jquery.bootstrap.js ,它非常小而且简单,与easyui相似。
$("#loginwrap").dialog({
title: "Login"
, buttons: [
{
text: "Close"
, classed: "btn-primary"
, click: function() {
$(this).dialog("close");
}
},
{
text: "Login"
, classed: "btn-success"
, click: function() {
//your login handler
$(this).dialog("close");
}
}
]
});