Skip to content

Preventing state reload on URL change #427

Closed
@roryf

Description

@roryf

I currently use the following code to prevent my route, and therefore controller, being reloaded when I update the $location:

angular.module('Shared').service('location', function($location, $route, $rootScope) {
  $location.skipReload = function () {
    var lastRoute = $route.current;
    var un = $rootScope.$on('$locationChangeSuccess', function () {
        $route.current = lastRoute;
        un();
    });
    return $location;
  };
  return $location;
});

along with:

location.skipReload().path("/newpath").replace();

Can I achieve the same behaviour with ui-router?

I tried simply replacing $route above with $state but this still resulted in a state change. My use case is I only have 'new' and 'edit' states which are exactly the same, when a user saves within the 'new' state I want to update the URL to include the saved id but not reload the view.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions