I have an Angular Universal app, by using this call on the CLI
ng add @nguniversal/express-engine --clientProject myapp
I generate an AboutComponent. And I give this AboutComponent it's own title using Title from '@angular/platform-browser'.
So this works! On the command line I use
npm run build:ssr
npm run serve:ssr
and then check the View Source in Chrome Dev Tools and see the different title for the about page.
Then I add a service worker using
ng add @angular/pwa
I run npm run build:ssr and npm run serve:ssr again and now the View Source in Chrome Dev Tools for the the about page shows the title from the index instead of the AboutComponent's specific title.
Is there some way to get Universal to keep the individual titles for each page and also have a service worker?
Here's my github: https://github.com/flocela/univ-servworker
Thank you.
EDIT: Here's my about.component.ts file:
import { Component, OnInit } from '@angular/core';
import {Title} from '@angular/platform-browser';
@Component({
selector: 'app-about',
templateUrl: './about.component.html',
styleUrls: ['./about.component.sass']
})
export class AboutComponent implements OnInit {
constructor(private title: Title) { }
ngOnInit() {
this.title.setTitle('About');
}
}