atticoos / angular-translate-once

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

Enable $translateOnce on controller level #19

Closed ericjames closed 6 years ago

ericjames commented 7 years ago

We have a single-page app that rotates languages. However I would like to use translate-once when this functionality is disabled. Could I invoke it in a controller ie:

myApp.controller('myCtrl', function($translateOnce) { 
    if (myRotatorDisabled) { 
     $translateOnce.enabled(true);
   }
});

Or at least as provider?

myApp.config(function($translateOnceProvider) {
 $translateOnceProvider.enabled();
});
vviikk commented 6 years ago

This directive is what it is - a directive. You can achieve what you're looking for by use the regular $translate service to translate your string - and storing that string, and calling it in your view using a ng-bind='::scope.yourString' - this way you are basically using one-time binding.