Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

onReady usage #1287

Closed
marcelorio opened this issue Nov 5, 2015 · 8 comments
Closed

onReady usage #1287

marcelorio opened this issue Nov 5, 2015 · 8 comments

Comments

@marcelorio
Copy link

The rootscope solution works, but the onReady solution presents as being ready, but doesn't work. Am I using it correctly?

I am using angular-translate 2.8.1 and angular 1.4.6

$translatePartialLoader.addPart('pages/cadastros/unidade-metrica');

           $rootScope.$on('$translateChangeSuccess', function () {
                $scope.label.yes = $translate.instant('Cost_UnitOfMeasure_Yes');
            });

            $translate.onReady().then(function () {
                if ($translate.isReady()) {
                    $scope.label.no = $translate.instant('Cost_UnitOfMeasure_No');

                }
                console.log($translate.isReady()); // returns true but translation isn't loaded
            });
@knalli
Copy link
Member

knalli commented Nov 5, 2015

@marcelorio Do you using 2.8.1? Because the bug with isReady() should be fixed.

$translate.onReady() is already a promise which does not require to check for isReady().

@knalli
Copy link
Member

knalli commented Nov 5, 2015

Ah, I have missed your said already using 2.8.1.

So, no you don't have to call isReady(), although it should work and looks like the bug was not fixed in 2.8.1

@marcelorio
Copy link
Author

Thank you for the fast reply knalli.

Indeed the isReady() inside the onReady() is a bit redundant. I only used it as a test to see if it would show up in the console, and it does, but the translation isn't loaded.

@matikun86
Copy link

I don't know if it's the same cause but I was using $translateProvider.preferredLanguage and I think that was firing the onReady callbacks. I removed that line and onReady fired correctly (at least the first time)

@knalli
Copy link
Member

knalli commented Nov 13, 2015

What do you mean?

@marcelorio
Copy link
Author

I was using $translateProvider.preferredLanguage, but taking it from the code did not solve the problem..

@knalli
Copy link
Member

knalli commented Dec 13, 2015

knalli added a commit that referenced this issue Dec 27, 2015
In special situations like loading additional languages, the cloak has not been removed/applied correctly after some time.

Fixes #1287
@knalli knalli added this to the 2.9.0 milestone Dec 27, 2015
@knalli
Copy link
Member

knalli commented Dec 27, 2015

In combination with a condition I 've fixed a bug. I'll close this in favor.

@knalli knalli closed this as completed Dec 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants