1

There seem to be two answers to this question:

    $scope.cancel = ->
      location.reload()

or:

    $scope.cancel = ->
      $route.reload()

The first works fine but it is a full GET and seems to be doing a lot more work than needed. The second doesn't seem to work at all -- I can see it hitting the reload method and queuing up the updateRoute function with this.$$asyncQueue.push(expr) but the reload doesn't happen. Can I force $route.reload to work? Is there a better way to accomplish this?

Related SO post, but answer doesn't work.

1 Answer 1

2

Have you tried $location.path(..) ? angular $location service

 # this code handles the funky url that gets generated and keeps 
 #    the funk to a minimum
 # moment is a js library for dealing with time
 # typical url looks like: 
 # http://192.168.101.111:3001/#/admin/user/edit/M6E8WANLIAF%231376602267119
 # moment tag is after %23 and angular seems to deal with it just fine
    $scope.cancel = ->
      if (/#/.test($location.$$path))
        $location.path($location.$$path.replace(/#.*/, "##{moment()}"))
      else
        $location.path($location.$$path += "#" + moment());
Sign up to request clarification or add additional context in comments.

3 Comments

Kinda, I just tried $location.$$path += "#" + moment(); which produced "/admin/user/edit/U4B7O08P4LG#1376601341118" and then route.reload but it didn't do anything.
I believe you don't need to do a route.reload if you just try a $location.path($location.path()+'#'+moment()), just a suggestion, might help
Looks like that did it. I'll put my answer in your answer. Feel free to edit it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.