mm1975
mm1975

Reputation: 1655

Get date format of actual loaded locale script

I dynamically import the locale script to i18n my application:

$scope.setCountry = function(countryKey) {
        // Dynamically load i18n Angular locale depending on country select
        var imported = document.createElement('script');
        var fileImport = 'angular-locale_' + countryKey + '.js';
        console.log(fileImport);
        imported.src = 'i18n/angular-locale/' + fileImport;
        document.head.appendChild(imported);
};

How do I get the actual loaded date format? for e.g. the shortDate?

I need it like this: dd/MM/y (UK for e.g.) Thank you!

Upvotes: 2

Views: 1420

Answers (1)

harishr
harishr

Reputation: 18065

use $locale service and then read the date format using $locale.DATETIME_FORMATS.medium

Upvotes: 3

Related Questions