angular ui-router:如何在路径参数更改时重新加载状态,但在查询参数更改时不重新加载?

例如,我希望导航中的这种更改重新加载状态:

For example, I want this change in navigation to reload the state:

  • #/detail/1
  • #/detail/2

但我不希望这个导航重新加载状态:

But I do not want this navigation to reload the state:

  • #/detail/1?search=blah
  • #/detail/1?search=huzzah

根据 ui-router 文档,设置 reloadOnSearch: false 应该可以完成此操作,但请尝试下面的 plunk.当 reloadOnSearch === false 时,更改路径参数不会重新加载状态,即使文档说明它应该这样做.

According to the ui-router documentation, setting reloadOnSearch: false should accomplish this, but try the plunk below. When reloadOnSearch === false, changing the path parameter doesn't reload the state even though the documentation says it should.

Plunkr:http://run.plnkr.co/ZPy9uabYlkMilwdS/#/param

推荐答案

这是 UI-Router 中的一个错误,已在 0.2.15 版本中修复:

This is a bug in UI-Router that was fixed in release 0.2.15:

https://github.com/angular-ui/ui-router/releases

升级到最新版本将解决问题

Upgrading to the latest will fix the issue

相关文章