【发布时间】:2014-04-26 00:05:52
【问题描述】:
我尝试将更改路由的提示写入控制器。
代码:
<a href="#/">Test</a>
<a href="#/Test2">Test2</a>
<hr/>
<div ng-app='app'>
<pre>View:
<ng-view></ng-view>
</pre>
</div>
JS:
console.clear();
var app = angular.module("app",["ngRoute"]);
app.controller("Test1", function($rootScope){
var $offFunction = $rootScope.$on("$locationChangeStart", function(e) {
if (confirm("Are you sure")) return $offFunction();
return e.preventDefault();
});
})
app.config(function($routeProvider){
var tmpl1 = "Show message when you try change route. Bug: \n1. Click to 'Test2'. On prompt click cancel."
+"\n2. Click to Test2 again"
+"\n3. There is no prompt message"
+"\n <i>Only on IE</i>";
$routeProvider
.when("/", {template:tmpl1, controller: "Test1"})
.when("/Test2", {template:"Test 2"})
})
问题:
在 IE11 和 IE10 中,如果您单击到 Test2,请选中“取消”并再次单击到 Test2 - locationChangeStart 不会再次调用。如何解决?
IE9 一切正常
【问题讨论】:
标签: angularjs internet-explorer-11