AngularJS - check if a string matches a route

Is there a way in angular if the following route is given

.when('/customer/:customerId', {
    templateUrl: 'views/summary.tpl.html',
    controller: 'SummaryController'
})

to check if a string matches this route?

For example, with the string

'/customer/3'

is there a function in angular that i can call to determine if a route matches a route or not?

+4
source share
2 answers

You can iterate over all specific routes and check if there is a match:

angular.forEach($route.routes, function(route) {        
    if(route.regexp.exec(myURL)){
        match = true;
    }        
})

Check this script .

+2
source

This is a good question, which I also dealt with. Here you can find inspiration:

https://github.com/angular/angular.js/issues/2274

, , - , . , " ". URL-, , .

+1

All Articles