S
S
Sergey2015-06-12 09:06:05
Angular
Sergey, 2015-06-12 09:06:05

Am I understanding the decorator correctly?

I am using angular-translate for translation. But I really need to have this feature

$scope.CurrentLanguage = function () {
            var CurrentLanguage = $translate.use() || $translate.storage().get($translate.storageKey()) || translate.preferredLanguage();
            return CurrentLanguage;
        };
working "everywhere" in the application. Can I do in the general config something like
app.config(function($provide) {
  $provide.decorator('$translate', function($delegate) {
    $delegate.getCurrentLanguage = function() {
      var getCurrentLanguage = $translate.use() || $translate.storage().get($translate.storageKey()) || $translate.preferredLanguage();
    };
    return $delegate;
  });
});

Is it correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2015-06-12
@TsarS

Yes, in this case it is quite appropriate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question