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.

I am using ngTable that use filters in the format filter[foo], filter[bar], sorting[foo], sorting[bar].
I want to pass this parameters as URL, but as I am using UI Router, I need to declare them in the state definition.
So I tried to setup a state like this

  .state('admin.results', {
    url: '/results?filter[foo]',
    templateUrl: 'app/results.tpl.html',
    controller: 'ResultCtrl'
  })

but the square brackets look to be interpreted as a regex, so I get an error like this

Invalid parameter name 'filter[foo]' in pattern '/results?filter[foo]'

I also tried escaping the brackets url: '/results?filter\[foo\]' but again I receive the same error.
You can try it in this plunkr.

share|improve this question

1 Answer 1

Try:

$routeProvider.when('/results/:filter', {
  controller: 'typeFormController',
  templateUrl: 'app/results.tpl.html'
});

And in your controller use $routeParams.filter to get your filter

share|improve this answer
    
Thanks, but I need filter to be a query parameter, not a url parameter. I don't think this would accept /results?filter[foo]. –  pasine Mar 17 at 15:15

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.