Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS ui-router- Use filters in ui-sref with parameters?

Suppose if we have to modify or do some prepossessing on parameters of ui-sref like below:

ui-sref="post({postId: post.post_id, postTitle: post.post_title | myFilter )})"

As shown if I want to apply my custom filter to parameter, is there any way to it?

I have tried like above, but it didn't worked and was giving syntax color.

The other solution could be probably to modify attribute in controller only, but that it not feasible for me, as these data is coming from server in list and I don't think to pre-process it in controller is good idea just for this.

Any suggestions this can be achieved?

like image 785
Kalpesh Patel Avatar asked Jul 30 '14 09:07

Kalpesh Patel


1 Answers

Yes you can, however you need to wrap each parameter in parenthesis like so:

ui-sref="post({postId: (post.post_id | myFilter), postTitle: (post.post_title | myFilter)})"

Example, using lowercase filter:

ui-sref="post({postId: (post.post_id | lowercase), postTitle: (post.post_title | lowercase)})"
like image 59
Stu Avatar answered Sep 26 '22 20:09

Stu