AngularJS: Change hash and route without completely reloading controller

前端 未结 10 1232
鱼传尺愫
鱼传尺愫 2020-12-07 19:29

I have a controller, with a route like this:

#/articles/1234

I want to change the route without completely reloading the controller, so I can keep the positi

10条回答
  •  隐瞒了意图╮
    2020-12-07 19:54

    If you land here in 2015: The real answer here is to use none of these hacks (I dare name them so, because by using any of the methods listed above you will lose the possibility to use resolve and the likes) but to switch to ui-router.

    Here's a handy presentation on the differences. Implementation should be as simple as swapping $route for $state and converting the states to names.

    I'm currently switching over to a method where i will refer with an a href to a route, with an optional get parameter that changes the state without reloading it. For more on this, look at the 'params' section here

提交回复
热议问题