i'm simply doing setting this:
app.config(['$routeProvider',function($routeProvider) {
$routeProvider
.when('/asd/:id/:slug',{
templateUrl:'views/home/index.html',
controller:'Home',
publicAccess:true,
sessionAccess:true
});
:id and :slug are dynamic params.
Now i would like to check if current url matches
that route (/asd/:id/:slug
)
for example the url : asd/5/it-is-a-slug
which is the simplest way?
i tryed this :
$rootScope.$on('$routeChangeStart', function(){
console.log($route.current);
});
but sometimes it returns nothing in console while switching page routes
$route.current
to get the current route. Don't need to map the url. – KearyHome
controller because multiple routes could be mapped to it? As @KhanhTO said, inject$route
and check$route.current.params
or whatever. Though I think your code should care more about whether you have params than whether the URL matched. If completely different URLs with different meanings are hitting the same controller, you should probably use a different controller. – Marion