K
K
Kirill Gorlov2015-10-07 14:56:23
JavaScript
Kirill Gorlov, 2015-10-07 14:56:23

How to delay the loading of a View until a specific event?

There is a View that uses the DatePicker from the AngularJS-ui-bootstrap distribution.
This plugin uses localization files, which in turn are loaded dynamically depending on the selected locale in the EN or RU user interface.
The problem is that the Locale is loaded AFTER the Display is loaded and rendered.
How to force Angular to render the Display after finishing loading the Localization file.
the tmhDynamicLocale module is used.
Main controller code:

self.loadLocale = function () {

            var locale = '';

            if($translate.use() == 'en') { locale = 'en-us'; }
            if($translate.use() == 'ru') { locale = 'ru-ru'; }


            tmhDynamicLocale.set(locale == 'en-us' ? 'ru-ru' : 'en-us')
            .then(
                tmhDynamicLocale.set(locale == 'en-us' ? 'en-us' : 'ru-ru')
            )
            .then(function() {
                $rootScope.$broadcast('localeLoaded');
                console.log('CURRENT LOCALE :: ' + locale);
            });

        };

The fact is that the next time you change the language, everything is loaded as it should, and at the first boot, only in Russian version, for some reason the main language is English.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question