angularjs modal 嵌套modal的問題


anguarjs中當遇到modal嵌套modal的時候,比如一個modal彈出啦一個modal1,關閉modal1后,modal本身的關閉功能失效,那么需要$modal來生命彈出的modal1並且關閉

js:

.controller('infoWindowCtrl', function($scope,NiDialog,$modal) {
$scope.showInfo = function(obj,title) {
var modalInstance;
modalInstance=$modal.open({
windowClass: '',
size:'tableContent',
backdrop: 'static',
keyboard: false,
templateUrl: '/static/tpl/front/order/contactInfo.tpl',
controller: 'contactCtrl',
resolve:{
id:function(){
return obj.$parent.model.id;
},
title:function(){
return title;
}
}
});
}

})
.controller('contactCtrl', function($scope,NiDialog,NiHttp,$modalInstance,id,title) {
var vm = $scope.vm = {};
var fn = $scope.fn = {};
fn.close=function(){
$modalInstance.close();
}
}])

To close a $modal that you have opened you can follow these steps.

1) Inject $modalInstance into the controller that you specified when you created the modal. In your case you called it contactCtrl.

2) Have a function in your ModalInstanceCtrl that calls .close() on $modalInstance.

 

具體參考:http://plnkr.co/edit/SpEx6Y?p=preview


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM