Angular | Set Page title dynamically based on API call
- Import the
Titleservice in your component:
import { Title } from '@angular/platform-browser';
2. Inject the Title service in the constructor of your component:
constructor(private titleService: Title) {}
3. Set the page title using the setTitle method of the Title service in the subscribe callback:
this.pageTitle = data.PageTitle;
this.titleService.setTitle(this.pageTitle); // Set the page title dynamically