I defined a $routeProvider
that adds access
to the route:
$routeProvider.when('/tracks/:trackTitle/:mediaTitle',
{
templateUrl: 'views/track-detail.html',
controller: 'MediaCtrl',
access: access.user
...
}
I am listening to $routeChangeStart
change event and check that the user can access the page. If the does not I save the route in the cookiestore and load it after the user logs in.
$rootScope.$on("$routeChangeStart", function (event, next, current) {
$rootScope.error = null;
if (!Auth.authorize(next.access)) {
if (!Auth.isLoggedIn())
$cookieStore.put('current.user.originalPath', originalPath);
$location.path('/signup');
}});
The problem is that the next
object for some reason changes between the put and get from the cookiestore.
Before the $cookieStore.put
next is:
$$route: Object
params: Object
pathParams: Object
__proto__: Object
And when I get the object using $cookieStore.get
the value is
params: Object
pathParams: Object
__proto__: Object
I am getting the object without $$route object.
Why is that and how can I fix it?