尽管选项 reloadOnSearch 设置为 false,但强制 AngularJS 重新加载路由 [英] Force AngularJS to reload a route although option reloadOnSearch is set to false

查看:25
本文介绍了尽管选项 reloadOnSearch 设置为 false,但强制 AngularJS 重新加载路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 AngularJS 应用程序的路由配置中,大多数路由是使用选项 reloadOnSearch 设置为 false 定义的,因为在大多数情况下,页面不应在搜索时重新加载参数改变.

In the route configuration of my AngularJS application most of the routes are defined with the option reloadOnSearch set to false as most of the time a page should not reload when search parameter changed.

但在极少数情况下,我需要一个不同的行为,我需要重新加载 URL,尽管只有搜索参数发生了变化.

But in rare circumstances I need a different behaviour where I need to reload the URL although only the search parameters changed.

有没有办法强制 AngularJS 重新加载 URL,尽管 reloadOnSearch 设置为 false?

Is there a way to force AngularJS to reload the URL although reloadOnSearch is set to false?

推荐答案

我没试过,但你可以尝试一下.

I have not tried it, but something that you can try is.

$routeUpdate 事件处理程序中调用 $route.reload() 方法,如果你知道应该导致路由刷新的条件.

In the $routeUpdate event handler call the $route.reload() method if you know the condition that should cause refresh of route.

这篇关于尽管选项 reloadOnSearch 设置为 false,但强制 AngularJS 重新加载路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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