IE中window.location.assign(url)的角度消化误差

时间:2014-04-29 15:05:10

标签: javascript angularjs internet-explorer

我使用角度js,每当我尝试使用window.location.assign(url)更改窗口位置网址时,我都会收到以下错误。这只发生在IE中 这是我得到的错误:

10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: function $locationWatch() {\n      var oldUrl = $browser.url();\n      var currentReplace = $location.$$replace;\n\n      if (!changeCounter || oldUrl != $location.absUrl()) {\n        changeCounter++;\n        $rootScope.$evalAsync(function() {\n          if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n              defaultPrevented) {\n            $location.$$parse(oldUrl);\n          } else {\n            $browser.url($location.absUrl(), currentReplace);\n            afterLocationChange(oldUrl);\n          }\n        });\n      }\n      $location.$$replace = false;\n\n      return changeCounter;\n    }; newVal: 9; oldVal: 8","fn: function ngModelWatch() {\n    var value = ngModelGet($scope);\n\n    // if scop

我的JS代码从中调用:

$scope.onRowClick = function(selected, row, $event) {       
        if(selected){
            window.location.assign("/lora/#/origination/" + row.loanRequestNo); 
        }
    };

我的路由器js。

var app = angular.module('loraApp', []);

app.config([ '$routeProvider', function($routeProvider) {
    $routeProvider.when('/dashboard', {
        templateUrl : 'app/html/dashboard.html'
    }).when('/origination', {
        templateUrl : 'app/html/origination/origination.html' , controller: 'OriginationCtrl'
    }).otherwise({
        redirectTo : '/dashboard'
    });
} ]);

我尝试从/ dashboard导航到/ originination。但是,当我尝试从/ originination转换为/ originination时,也会发生这种情况。基本上只要我的代码遇到window.location.url

就会发生这种情况

1 个答案:

答案 0 :(得分:4)

您需要将$location注入控制器,然后使用$location

设置路径
$location.url('/organization/' + row.loanRequestNo);

$location documenation

编辑根据您定义的路线,您不会收到参数row.loanRequestNo。您将需要更新该路线:

/organization/:loadRequestNo

通过$routeParams

在目标控制器上捕获它

编辑 Working Fiddle