Angular 2

Page title

Introduction#

How can you change the title of the page

Syntax#

  • setTitle(newTitle: string): void;
  • getTitle(): string;

changing the page title

  1. First we need to provide Title service.

  2. Using setTitle

    import {Title} from “@angular/platform-browser”; @Component({ selector: ‘app’, templateUrl: ‘./app.component.html’, providers : [Title] })

    export class AppComponent implements { constructor( private title: Title) { this.title.setTitle(‘page title changed’); } }


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow