【问题标题】:angularjs redirect to another page after POST generates error in IE [duplicate]POST在IE中生成错误后,angularjs重定向到另一个页面[重复]
【发布时间】:2016-12-21 00:47:56
【问题描述】:

我是 Angular 的新手。

我正在尝试根据 API 的响应从当前页面重定向到另一个页面。

重定向正在发生,但代码在 IE 浏览器中无法正常运行,但在 Chrome 中运行正常。

有人可以帮忙解释一下为什么会出现这个错误吗?

IE 控制台出错:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

SCRIPT5022: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations:

JS 文件:

app.config(function($routeProvider){   $routeProvider
        .when('/findCustomer', {
           templateUrl: 'CustomerList.html',
           controller: 'customerListController',
        })
        .when('/modifyCustomer', {
           templateUrl: 'ModifyCustomer.html',
           controller: 'modifyController',
        })

客户列表控制器:

service.getCustomerList().then(function(data) {
        if (data.length == 1) {
            $window.location.href= "#/modifyCustomer";
        }

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    谢谢博格

    这个问题在 IE 中也得到了解决。

    我使用过 $location.path("/modifyCustomer");而不是 $window.location.href="#/modifyCustomer";

    注意: 如果我在调用 POST 之前使用 window.location.href,那么页面重定向在 IE 中也是成功的……这就是为什么我无法找出问题所在

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-28
      相关资源
      最近更新 更多