Thursday, 15 March 2012

angularjs - Parameters array in Angular UI-Router -


I am using ngTable which uses the filter in the format filter [foo] , filter [bar] , sorting [foo] , sorting [bar] .
I want to pass this parameter as a URL, but as I am using the UI router, I need to declare them in the definition of the state.
I tried to establish a state like this

  .state ('admin.results', {url:' / results? Filter [foo] ', templateUrl:' App / results.tpl.html ', Controller:' ResultCtrl '})  

But the square bracket is interpreted as a regex, so I get an error like this

invalid parameter name 'pattern' / result filter [foo] 'filter [foo]'

I also tried to escape the bracket url: '/ Results? Again I get the same error on filter \ [foo \] '.
You can try it.

Try:

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

and use $ routeParams.filter to get your filter into your controller


No comments:

Post a Comment