Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So im currently trying to figure out the best way to work with multiple routes in angular. So for example I have this in my app.js:

myApp.config(['$routeProvider', function($routeProvider) {
  $routeProvider.
  when('/list/:1/:2/:3/:4/:5', {
    templateUrl: 'partials/list.html',
    controller: 'CustomCtrl'
  }).
  when('/details/:itemId', {
    templateUrl: 'partials/details.html',
    controller: 'DetailCtrl'
  }).
  otherwise({
    redirectTo: '/list',
    templateUrl: 'partials/list.html',
    controller: 'ListCtrl'
  });
}]);

Currently the application I am making can have UP TO 5 different parameters within the URL. (As seen above ex: www.example.com/#/list/1/2/3/4/5)

My question is when ONE (or any amount) of those parameters are missing let's say 4 (ex: www.example.com/#/list/1/2/3/5) it defaults to my regular 'ListCtrl'. Is there a possible way in angular to say.. Well even though parameter 4 isn't available I'll still goto your 'CustomCtrl' because I see that indeed some parameters are listed.

Or should I be coding this a completly different way all together? Thanks for the help!

share|improve this question
    
Just use GET variables at that point. –  Noah Matisoff 20 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.