0

Assume the following route provider:

    myApp.config(['$routeProvider', function($routeProvider) {        

    $routeProvider.when('/multivalues/:value/:value/:value',
    {templateUrl: 'partials/multivalues.html',
    controller: 'MultiValueController'});
}]);

Ideally, we would like the variable $routeParams.value to contain a list of 3 elements. It seems that angularJS does not support this functionality.

What is the best practice to implement this functionality?

Zouzias
  • 2,330
  • 1
  • 22
  • 32
  • 3
    I'm afraid it can't contain 3 elements. You should use different var names: '/multivalues/:value1/:value2/:value3' – Jevgeni Oct 01 '14 at 14:18
  • what you want to do? – BlaShadow Oct 01 '14 at 14:20
  • I would like to pass values in a route dynamically, i.e., "/multivalues/:value1/:value2/.../:value10" for passing 10 values. However, the number of different values might be less than ten. Of course, I do not want to write explicitly all the different routes from 1 to 10 ("/multivalues/:values1", "/multivalues/:values1/:values2", etc). – Zouzias Oct 01 '14 at 14:26
  • I don't know if this is possible, under what situation will you need to pass a varying number of params? – Jared Reeves Oct 01 '14 at 15:11
  • 1
    Have you considered something like `/:value` then using `$routeParams.value.split('&&')`? – Morgan Delaney Oct 01 '14 at 16:08
  • @MorganDelaney Thanks Morgan. Yes, this is one approach. I have just realized that it is possible to have optional route parameters which might be well suited for my problem. http://stackoverflow.com/questions/17510962/can-angularjs-routes-have-optional-parameter-values – Zouzias Oct 01 '14 at 18:14

0 Answers0