AngularJS ui-router: reload:true also reloads parent state

前端 未结 2 1120
粉色の甜心
粉色の甜心 2021-01-18 02:15

In this plunk you have two ui-router states, a parent and a child. When the child is invoked by clicking on the link, since it has the option reload: true it is

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 02:30

    It's actually very simple.

    Don't use reload because that does exactly what you found. It reloads everything for the route.

    Instead, add a parameter to your child route and every time the link is clicked make sure to change that parameter. That will force the child state to be reloaded.

    I updated your plunk with an example. I just added a num parameter and increase a count variable each time the link is clicked.

    http://plnkr.co/edit/qTA39rrYFYUegzuFbWnc?p=preview

提交回复
热议问题