Skip to content

Instantly share code, notes, and snippets.

@Walgermo
Walgermo / meta.service.ts
Last active January 22, 2021 20:33
Angular 6 - Globally set meta title in app on route change
import { Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { filter, map, mergeMap } from 'rxjs/operators';
/**
* Call updateTitle() from app.component.ts contructor.
* Example app.component.ts:
constructor(private meta: MetaService) {
this.meta.updateTitle();