Change url using Angular UI-Router, don't do anything

There seems to be no built-in way to update the URL without executing all other processes, for example. calling controllers.

The reboot option only works with $location.search()

Is there a way or approach to achieve

How can I achieve something like this:

$state.go('stateName', params, {justChangeTheUrl: true})

With Angular UI-Router?

+4
source share
2 answers

If you just want to change the URL without changing the change using ui-router, you can use the following acceptable hack (coffeescript):

scopeOff = $scope.$on '$stateChangeStart', (e) ->
  e.preventDefault()
  scopeOff()

$location.path 'just/change/the/url'

Notes

URL- $location.path() , ui-router . ui-router, $stateChangeStart.

, , e.preventDefault() $stateChangeStart ui-router URL-.

$stateChangeStart "", ( , scopeOff()).

URL- ui-router URL-, . , , deferIntercept, .

+3

URL

 $stateProvider.state('stateName', {
     url: '/state/path?reload'
 });

, $location.search() reload param $stateChangeStart,

0

All Articles