I'm having an issue with changing the URL of the page after a form has been submitted.

Here's the flow of my app:

1. Routes are set, URL is recognized to some form page.
2. Page loads, controller sets variables, directives are fired.
3. A special form directive is fired which performs a special form submission using AJAX.
4. After the AJAX is performed (Angular doesn't take care of the AJAX) then a callback is fired and the directive calls the `$scope.onAfterSubmit` function which sets the location.

The problem is that after setting the location the nothing happens. I've tried setting the location param to `/` as well... Nope. I've also tried not submitting the form. Nothing works.

I've tested to see if the code reaches the `onAfterSubmit` function (which it does).

My only thought is that somehow the scope of the function is changed (since its called from a directive), but then again how can it call `onAfterSubmit` if the scope changed? 

Here's my code

```
var Ctrl = function($scope, $location, $http) {
  $http.get('/resources/' + $params.id + '/edit.json').success(function(data) {
    $scope.resource = data;
  });

  $scope.onAfterSubmit = function() {
    $location.path('/').replace();
  };
}
Ctrl.$inject = ['$scope','$location','$http'];

```

Can someone help me out please?