In Angular, change the title

Update  the app.component.ts file

import { Component } from '@angular/core';
import { Title } from '@angular/platform-browser';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent {
  theme: boolean = false;
  newTitle: any;
  constructor(public title: Title) {}
  ngOnInit() {
    this.title.setTitle('Dashboard');
    setInterval(() => {
      this.newTitle = this.title.getTitle();
      if (this.newTitle == 'Dashboard') {
        this.title.setTitle('Home-page');
      }
      if (this.newTitle == 'Home-page') {
        this.title.setTitle('Dashboard');
      }
    }, 1000 * 1);
  }
}

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories