我使用角度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
就会发生这种情况答案 0 :(得分:4)
您需要将$location
注入控制器,然后使用$location
$location.url('/organization/' + row.loanRequestNo);
编辑根据您定义的路线,您不会收到参数row.loanRequestNo。您将需要更新该路线:
/organization/:loadRequestNo
在目标控制器上捕获它