In diesem PLUNK habe ich ein Angular UI Modal und eine Schaltfläche, um es zu schließen. Die Schaltfläche funktioniert nicht, da die Modal-Instanz keine Methode close
hat.Schließen Sie die Schaltfläche funktioniert nicht in eckigen UI Modal
Wenn Sie die rendered
Anweisung entfernen, funktioniert die Schaltfläche. Warum funktioniert es nicht MIT rendered
?
funktioniert das nicht:
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();
};
})
Diese (siehe PLUNK) funktioniert:
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();
};
})