I'm using ngRoute in angularjs to delegate different html templates, eg:
phonecatApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl'
}).
when('/cars', {
templateUrl: 'partials/car-detail.html',
controller: 'CarDetailCtrl'
});
//many more routes
}]);
Problem: I want to have a common url, like localhost/my-app?myparam=Nokia.
I want to compare the myparam to a mapping table. If the param name is a phone company, I want to delegate to /phones. If it's a car company, I want to delegate to /cars, etc. You get the idea.
Also I have to rewrite the url as follows: localhost/myapp/phones?myparam=Nokia. Thereby the ngRoute would automatically catch the correct template and controller.
Question: how can I intercept the initial loading, and redirect based on the url param?
Sidenote: I cannot rewrite the routeProvider config eg by using a different plugin like angular-ui-router.