解雇URL变化角度模式 - 在控制台错误 [英] Dismiss angular modal on URL change - errors in console

查看:130
本文介绍了解雇URL变化角度模式 - 在控制台错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的角度引导模态显示一个弹出窗口。在点击文本区域/浏览器后退按钮外退格,我想取消弹出并继续URL变化。默认行为是背后的模态变化的页面,但依然模式之上。

I'm using Angular bootstrap Modal to show a popup window. On clicking backspace outside the textarea / browser back button, i want to cancel the popup and continue with the url change. The default behaviour is that page behind the modal changes, but the modal remains on top.

在控制器为模式的情况下,我增加了一个

In the controller for the modal instance, I added a

$ $范围在('$ routeChangeStart',函数(){...});

$scope.$on('$routeChangeStart', function() {...} );

它的工作原理,但我发现错误,每当控制器再次调用。在$ modalInstance.dismiss()再次调用,但库中,它抛出一个异常。

It works, but I'm seeing errors whenever the controller is invoked again. The $modalInstance.dismiss() is called again, but inside the library, it throws an exception.

下面是用code和再现步骤的plunkr。留意错误的浏览器控制台。

Here's the plunkr with code and repro steps. Watch the browser console for the error.

http://plnkr.co/UKXa6uFvy0ODHylMj28s

难道我做错了什么,或者是在modal.js一个bug?

Am I doing something wrong, or is it a bug in modal.js?

编辑:我不认为我的控制器范围内是正确的。为什么会AddCtrl的$范围。在$('$ routeChangeStart'来当我浏览到MainCtrl叫什么?

I don't think my controller scope is right. Why would AddCtrl's $scope.$on('$routeChangeStart' be called when I navigate to MainCtrl?

推荐答案

您plunker似乎是正确的。

Your plunker seems to be right.

有$是服务模式的错误在这里:模态范围还活着关闭模式窗口后。因此,模态范围继续听 $ routeChangeStart ,我认为的两个人通话解雇()导致错误。

There is $modal service bug here: the modal scope is still alive after you close a modal window. So modal scope continue to listen $routeChangeStart and I consider that double call of dismiss() cause an error.

这个问题将在明年UI引导版本来解决。

This issue will be solved in next UI Bootstrap release.

我更新和评论你的code,希望这有助于 - http://plnkr.co/edit/daf8dP p =信息

I update and comment your code, hope this help - http://plnkr.co/edit/daf8dP?p=info

这篇关于解雇URL变化角度模式 - 在控制台错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆