Angular 2 name of the router with the parameter

Assuming I use the following expression to set the page title for the angular component in my router:

{path: 'view-move /: moveName', component: ViewMoveComponent, data: {title: 'View Move'}}

Assuming I use router parameters to get Move information, including its name, how can I put the move name inside my header, so it would be like this:

View Move: Move Name

Update: I tried:

import { BrowserModule, Title }  from '@angular/platform-browser';

constructor(public http: Http,private route: ActivatedRoute,private titleService: Title) {
this.titleService.setTitle("My Title");
  }

Now no title

+4
source share
1 answer

You need to enter TitleServiceinto your component and use its method setTitle.

https://angular.io/docs/ts/latest/cookbook/set-document-title.html

0

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


All Articles