atticoos / angular-translate-once

:currency_exchange: Extension of angular-translate for one time bindings
53 stars 11 forks source link

Translate-one as angular expression #15

Open studentIvan opened 8 years ago

studentIvan commented 8 years ago

For example i want to optimize this case:

<span translate-once="BUYER" ng-if="deal.getMyRole() == 'BUYER'"></span>
<span translate-once="SELLER" ng-if="deal.getMyRole() == 'SELLER'"></span>

Why I can't use it like below?

<span translate-once="deal.getMyRole()"></span>
atticoos commented 8 years ago

translate-once receives values as attribute strings, so expressions will not work unless they're part of an interpolation string.

Give this a try with

<span translate-once="{{deal.getMyRole()}}"></span>

The big hint is that normal strings work, translate-once="BUYER", but expressions don't. That usually implies it's not interpretted