0

I would like to provide a dynamic route with AngularJS and get an array of value, like we would do with GET request parameters : (/?id[]=1&id[]=2..) I do not know if angular js provides a "clean" way like :

/array/of/value/[1,2,3,4] 

And get the array with ngRoute and $routeProvider :

.when("/list/:arrayOfValue", {templateUrl: "./partials/list.html", controller: "ListController"})
  • You can find the answer to your question here: http://stackoverflow.com/questions/34601851/dynamic-routing-with-array-item-in-angularjs-after-filtering-array – Avantika Saini May 30 '16 at 10:41

1 Answers1

0

If you are using ui-router module, just inject the $state, and use $state.params.arrayOfValue

myModule.controller('myController', ['$state', function($state) {
   var myArray = $state.params.arrayOfValue;
});

I tested it, and it's working with array of numbers or string:

/array/of/value/[1,2,3,4]
/array/of/value/['test', 45, 'app'] 
Muhammad Hamada
  • 725
  • 5
  • 13
  • Thanks for your answer, but unfortunetly my app isn't based on ui-router. I tryed to include it to my app because this seems relevant related to my problem but my app needs ng-route and its route provider. You might have another solution. I could parse this piece of string by myself. – Robin Delaporte May 30 '16 at 10:15