Get the value of --locale on runtime for an AOT compiled Angular App Get the value of --locale on runtime for an AOT compiled Angular App angular angular

Get the value of --locale on runtime for an AOT compiled Angular App


As a newbie I found Simons answer a bit incomplete. Turns out that you need to import both LOCALE_ID and Inject:

import { Component, OnInit, LOCALE_ID, Inject } from '@angular/core';@Component({  selector: '...',  templateUrl: '...',  styleUrls: ['...']})export class ShinyComponent implements OnInit {  constructor(@Inject(LOCALE_ID) protected localeId: string) { }  public someFunction {} {    console.log("Current locale is "+this.localeId);   }}ngOnInit() {}


You should have Angular inject the LOCALE_ID

constructor(private modalService: BsModalService,    @Inject( LOCALE_ID ) protected localeId: string) {    console.log("LOCALE_ID", localeId);}