I am working in angular2 vs typescript.
In my app.component.ts file i have to load the script files on demand based current navigator language. So i have added my function like below(home.component.ts),
export class HomeComponent { constructor() { this.loadDynmicallyScript(); } public loadDynmicallyScript() { let node = document.createElement('script'); node.src = "../node_modules/xxxxxxxxxx/xx." + navigator.language"+".min.js"; node.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(node); } But this not works. But i have to load the files on demand based on current navigator language. How to achive this? Thanks for any help.