How to get the attributes from index.html

I want to get the value of the lang tag of my index.html which looks like this: <html dir="ltr" lang="en_US">

All I found is using the ElementRef in my app.component.ts, but the problem is, the index.html's tag is outside the angular app's scope, so I can't get reference to it. Any idea how to solve this?

1 answer

  • answered 2018-04-17 05:02 Arash

    you can use just javascript

    document.documentElement.lang
    

    or

    document.getElementsByTagName('html')[0].getAttribute('lang');
    

    And with the namespace

    document.getElementsByTagName('html')[0].getAttribute('xml:lang');