问题描述
有没有办法来调用 history.pushState()
无角进入无限循环消化?
Is there a way to call history.pushState()
without angular going into an infinite digest loop?
我想我的应用程序从后端布线转移到前端的路由和所有的计算器帖子谷歌似乎资源/不有一个答案。
I'm trying to migrate my app from backend routing to frontend routing and all the stackoverflow posts/google resources don't seem to have an answer.
推荐答案
这是我们做的一定角度1.2.16应用在此基础上github上评论:https://github.com/angular/angular.js/issues/3924#issuecomment-48592773
This is what we do in an Angular 1.2.16 app based on this github comment: https://github.com/angular/angular.js/issues/3924#issuecomment-48592773
$location.url(myNewUrl);
$location.replace();
$window.history.pushState(null, 'any', $location.absUrl());
这code是控制器的一部分。
我用它来添加查询参数的URL,而不希望重新加载页面。它的工作原理在我们的案例。
This code is part of a controller.I'm using it to add a query param to the url without wanting to reload the page. It works in our case.
这篇关于成功调用history.pushState()从角没有Inifinite消化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!