In angular2, the route or component is switched by default, and the title of the page will not change.
angular2 provides data parameters to pass values in the routing settings, as follows
{ path: 'home', component: HomeComponent, data: { title: 'Home', aaa: 'aaaa', bbb: 'bbbb', ccc: "cccc"} }
path and component are commonly used properties, path is the display of the address bar, and component is the component called.
data can pass data and can be called within the component.
Parameter call
angular2 provides Title service to modify title.
The parameters that are set in the route can be obtained using the snapshot data property of ActivatedRoute.
as follows:
import { ActivatedRoute } from '@angular/router'; import { Title } from '@angular/platform-browser'; config: any; constructor( private route: ActivatedRoute, private titleService: Title ) { } ngOnInit(): void { // Get the config information from the app routing data = ; // Sets the page title (); }
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.