我可以寫一些函數來取消結果關閉嗎? 壞主意在ModalInstanceCtrl中保存模型。取消結果模式
app.controller('MainController', ['$scope', '$modal', function ($scope, $modal) {
$scope.edit =function (id) {
var modal = $modal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl'
});
modal.result.then(function(model) {
if (somethink_wrong) {
***CANCEL CLOSING***
}
});
};
}]);
app.controller('ModalInstanceCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close($scope.model);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
}]);