`ui-router` $stateParams vs. $state.params

前端 未结 7 972
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 08:07

With ui-router, it\'s possible to inject either $state or $stateParams into a controller to get access to parameters in the URL. Howev

7条回答
  •  星月不相逢
    2020-12-07 08:57

    Another reason to use $state.params is for non-URL based state, which (to my mind) is woefully underdocumented and very powerful.

    I just discovered this while googling about how to pass state without having to expose it in the URL and answered a question elsewhere on SO.

    Basically, it allows this sort of syntax:

    {{ thingy.referer }}
    

提交回复
热议问题