AngularJS UI-Router : Get the absolute URL of the state with the parameters

前端 未结 3 572
既然无缘
既然无缘 2020-12-24 10:28

I wanted to be able to change the address\' URL without changing the state, as to prevent rerendering. From my search, ui-router currently does not provide this

相关标签:
3条回答
  • 2020-12-24 10:50

    What about :

    $state.href($state.current.name, $state.params, {absolute: true})
    
    0 讨论(0)
  • 2020-12-24 11:05

    For getting the absolute URL without parameters, I'm finding I need to pass inherit: false, eg:

    $state.href('home', {}, {absolute: true, inherit: false})
    

    Without inherit: false I was getting any/all params that may be present.

    0 讨论(0)
  • 2020-12-24 11:15

    You should use $state.href().

    1. To get the absolute URL you can then use:

      $state.href('user.home.view', {}, {absolute: true});

    2. To get the URL with the parameters in place you need to add them as the second argument

    0 讨论(0)
提交回复
热议问题