从controller1
我打开一个这样的模式:
angular.module('myApp').controller('controller1', ['$scope', '$uibModal', function($scope, $uibModal) {
$scope.openFirstModal = function() {
var modalScope = $scope.$new();
var modalInstance = $uibModal.open({
templateUrl: 'views/modal1.html',
controller: 'modal1Controller',
scope: modalScope,
resolve: {},
size: 'lg'
});
modalScope.uibModalInstance = modalInstance;
};
}]);
然后,我打开一个这样的嵌套模式:
angular.module('myApp').controller('modal1', ['$scope', '$uibModal', function($scope, $uibModal) {
$scope.openSecondModal = function() {
// Open nested modal
var modalScope = $scope.$new();
var modalInstance = $uibModal.open({
templateUrl: 'views/modal2.html',
controller: 'modal2Controller',
scope: modalScope,
resolve: {},
size: 'lg'
});
modalScope.uibModalInstance = modalInstance;
// Close this modal
$scope.uibModalInstance.dismiss('cancel');
};
}]);
但最后一部分:
// Close this modal
$scope.uibModalInstance.dismiss('cancel');
...在嵌套模式中引发问题。在我的嵌套模式中没有任何作用:
angular.module('myApp').controller('modal2', ['$scope', '$uibModal', function($scope, $uibModal) {
$scope.test = function() {
console.log("test");
};
}]);
如果我删除有问题的代码,嵌套模式可以正常工作。
如何关闭第一个模态而不使嵌套模态失败?