0
我有下面的代碼:角度引導對話框打開從未
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。如果我將調試放在角度引導程序中,它將進入開放方法並返回承諾,但不會打開對話框。
http://plnkr.co/edit/tNokVEbRds78tBaVZtLH?p=preview
爲什麼?
據我所知你的「開放式承諾」將在關閉對話框解決:'+ result); } }); 你的modalCtrl在哪裏? – alfrescian
鏈接到jsfiddle請註冊 –
plunkr補充。我的錯 –