你可以做這樣的事情:
myApp.controller('ModalCtrl', ['$scope', '$modal', function($scope, $modal) {
$scope.open = function() {
var modalInstance = $modal.open({
templateUrl: 'modal.html',
controller: 'ModalInstanceCtrl',
resolve: {
params: function() {
return {
key: 'value',
key2: 'value2'
};
}
}
});
modalInstance.result.then(
function(result) {
console.log('called $modalInstance.close()');
alert(result);
},
function(result) {
console.log('called $modalInstance.dismiss()');
alert(result);
}
);
};
}])
從你controller
東西你能。
myApp.controller('ModalInstanceCtrl', ['$scope', '$modalInstance', 'params', function ($scope, $modalInstance, params) {
console.log(params);
$scope.ok = function() {
$modalInstance.close('this is result for close');
};
$scope.cancel = function() {
$modalInstance.dismiss('this is result for dismiss');
};
}]);
發現一個整潔的小提琴在此: http://jsfiddle.net/wjohtz0y/
嗨Thalaivar,你能回答這個問題https://stackoverflow.com/questions/43583136/bootstrap-modal-popup-open-and-close - 使用 - angularjs - 不工作 – Vinoth