成功调用history.pushState()从角没有Inifinite消化? [英] Successfully Call history.pushState() from Angular Without Inifinite Digest?

查看:165
本文介绍了成功调用history.pushState()从角没有Inifinite消化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来调用 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上评论:<一href=\"https://github.com/angular/angular.js/issues/3924#issuecomment-48592773\">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消化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆