RandomQuestion
RandomQuestion

Reputation: 6998

How to use ngBind with multiple filters in Angular

I have a ngModel data.type which is bound and I want to apply a filter actionType to it first and then add a prefix and then finally pass it to localize filter.

Something like:

<h3 data-ng-bind="'prefix.' + {{ data.type | actionType}} | localize "></h3>

So for e.g. if actionType filter returned my-action-type then I want to pass prefix.my-action-type to localize filter.

Is there anyway to do this?

Thanks

Upvotes: 2

Views: 3157

Answers (1)

mmm
mmm

Reputation: 2297

You can control the order of operations in angular expressions by wrapping an expression in parentheses, just like you can in javascript.

If you have nested parentheses, they are executed before their containing parentheses, and it should all happen left to right.

<h3 data-ng-bind="('prefix.' + (data.type | actionType)) | localize "></h3>

Upvotes: 2

Related Questions