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.

Community
  • 1
  • 1
jcollum
  • 43,623
  • 55
  • 191
  • 321

1 Answers1

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());
jcollum
  • 43,623
  • 55
  • 191
  • 321
sanz
  • 1,069
  • 1
  • 10
  • 26
  • Kinda, I just tried `$location.$$path += "#" + moment();` which produced "/admin/user/edit/U4B7O08P4LG#1376601341118" and then `route.reload` but it didn't do anything. – jcollum Aug 15 '13 at 21:16
  • 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 – sanz Aug 15 '13 at 21:18
  • 1
    Looks like that did it. I'll put my answer in your answer. Feel free to edit it. – jcollum Aug 15 '13 at 21:31