0
在這個PLUNK中我有一個Angular UI Modal和一個關閉它的按鈕。該按鈕不起作用,因爲模態實例沒有close
方法。關閉按鈕在Angular UI Modal中不起作用
如果刪除rendered
語句,該按鈕將起作用。爲什麼它不起作用rendered
?
這不起作用:
var app = angular.module('app', ['ui.bootstrap']);
app.controller('myCtl', function($scope,$uibModal) {
$scope.openModal = function() {
$scope.modalInstance = $uibModal.open({
templateUrl: 'myModalContent.html',
scope: $scope
}).rendered.then(function() {
alert("modal rendered")
});
};
$scope.close = function() {
$scope.modalInstance.close();
};
})
這不工作(見PLUNK):
var app = angular.module('app', ['ui.bootstrap']);
app.controller('myCtl', function($scope,$uibModal) {
$scope.openModal = function() {
$scope.modalInstance = $uibModal.open({
templateUrl: 'myModalContent.html',
scope: $scope
});
};
$scope.close = function() {
$scope.modalInstance.close();
};
})