Angular TranslateService translate <title> tag

Using TranslateServicein Angular, I want the tag <title>that is in index.htmlto be in different languages.

<title translate>application.title</title>

I translated all other html tags, if they are not custom html tags, then it looks like this:

{{"document.name"|translate}}

The problem may be that index.html is on a different level in the folders

CSI
| -app
.... | transport | | -index.html

+4
source share
1 answer

From angular docs :

Title

Angular HTML- ( <html>), HTMLTitleElement ( <title>). .

Title TranslateService

export class SomeComponent {
  constructor(private title:Title, private translate:TranslateService){}
  ngOnInit(){
    this.translateService.get("document.name").subscribe(name=>{
      this.title.setTitle(name);
    });
  }
}

, .

+6

Source: https://habr.com/ru/post/1677771/


All Articles