gpt4 book ai didi

jquery - Angular UI Bootstrap $scope.$modalInstance.close 导致 : Cannot read property 'value' of undefined

转载 作者:行者123 更新时间:2023-12-03 22:20:51 25 4
gpt4 key购买 nike

我有一些模态,其中 2 个工作正常,1 个在关闭时出现此异常。(它确实设法关闭模式,但 Angular 记录了此异常)。

我仔细观察发现,$modalInstance 是在 close 方法内定义的,但是 openedWindows.get($modalInstance) 返回未定义

我该如何解决这个问题?

最佳答案

这是 v0.10.0 中 $modal 的一个错误。请参阅this github issue ,并将在下一版本中修复。

@IvanZh在这里提供了类似问题的答案 - Dismiss angular modal on URL change - errors in console

在 Controller 中,执行 $modal.open 后,添加一个 finally block ,在其中显式将 modalInstance 设置为 null。在上面的问题中可以使用 plunkr 来关闭 URL 更改时的模式。你的应该非常相似。

$scope.modalInstance = $modal.open({
templateUrl: 'add.html',
controller: 'AddCtrl'
});
$scope.modalInstance.result.then(function() {
console.log('Success');
}, function() {
console.log('Cancelled');
})['finally'](function(){
$scope.modalInstance = undefined // <--- This fixes
});

关于jquery - Angular UI Bootstrap $scope.$modalInstance.close 导致 : Cannot read property 'value' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21768778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com