For a route defined like this:
$routeProvider
.when('/',
{
templateUrl:'views/login.html',
controller:'Login',
private:false
});
How can I access the private
property inside a $routeChangeStart
event for example?
Currently I'm using current.$$route.private
to get it, but it seems wrong.
Thanks.
$routeChangeStart
happens prior to the route changing, so you need to look atnext
. There's no need to usenext.$$route
since next inherits from$$route
.It is actually recommended to put all your custom data with routes inside a "data" object as such.
Here is how I access route params
The second parameter of the routeChangeStart event is the route object that is called. Another advantage is that anything in the
data
object is passed to children states.