我close is not a function
在尝试关闭由$uibModal.open()
我已将问题减少到最少的代码:
var app = angular.module('demoApp', ['ui.bootstrap']);
app.controller('DemoContrller', function($scope, $uibModal) {
var vm = this;
var myModalInstance = null;
vm.openModal = function() {
myModalInstance = $uibModal.open({
animation: true,
templateUrl: 'modalTemplate.html',
scope: $scope // important - want to reuse current scope and controller and not create new
}).result.then(function() {
console.log('fully closed with successful validation');
});
};
vm.onApplyModal = function() {
console.log('doing some validation and closing only if succeeded');
// ??? close is not a function, myModalInstance is a Promise
console.log(myModalInstance);
myModalInstance.close();
};
})
请在此处查看我的 Plunk:Cannot close uibmodal from a function in the same scope