Hello I created basic angularJS app with angular-translate module. In config except my routing I've got also $translateProvider
which is responsible for translations tables and prefered lenguage.
so this code:
$translateProvider.preferredLanguage('en');
is within Angular config()
function.
I know that config is executed first, before run()
, controllers and others. I also know that in config there must be only providers can't inject for example $rootScope
there.
In my project by calling single endpoint using $http
I gather information about country which user came into this app. This is happening in run()
.
I tried to use $rootScope
(in this run()
):
$rootScope.homeCountry = response.data.country;
$rootScope.homeCountryLower = $rootScope.homeCountry.toLowerCase();
console.log($rootScope.homeCountryLower);
it console out "pl" in my case but I ended up learning that I can not pass $rootScope
to config since it is not a Provider.
I need to pass this information to $translateProvider
in config function so I would be able to set prefered user lengauge according to user country.
How can I achieve that?