angularjs - A filter that only runs once? -
i made filter replaces key translation.
<label>{{'city' | translate}}</label>
the filter looks key city
in json file , returns value.
what didn't realize filters run... lot. after research see there better ways not willing complete refactor.
how can tell filter run once per key.
as workaround, pre-compiling templates , replacing calls translate
correct string. works cases there places key dynamic or translation function takes scope variable arguments
<label>{{'greeting' | translate:firstname:lastname}}</label>
i want angular one-time replace of these , never think again.
i want angular one-time replace of these , never think again.
this little ambiguous. if scope variable changes? want filter run each time changes? or mean when dom first compiled, whatever value scope variable has should passed filter, evaluated , statically set dom? if latter, recommend angular-bindonce, provides watchless binding scope dom.
after adding module dependency app, markup like:
<label bo-text="city|translate"</label>
Comments
Post a Comment