Currently our project is using default $routeProvider
, and I am using this "hack", to change url
without reloading page:
services.service('$locationEx', ['$location', '$route', '$rootScope', 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;
}]);
and in controller
$locationEx.skipReload().path("/category/" + $scope.model.id).replace();
I am thinking of replacing routeProvider
with ui-router
for nesting routes, but cant find this in ui-router
.
Is it possible - do the same with angular-ui-router
?
Why do I need this?
Let me explain with an example :
Route for creating new category is /category/new
after clicking
on SAVE I show success-alert
and I want to change route /category/new
to /caterogy/23
(23 - is id of new item stored in db)
i did this but long ago in version: v0.2.10 of UI-router like something like this::
This setup solved following issues for me:
.../
to.../123
State configuration
Invoking the states (from any other controller)
Training Controller