Monday, 22 April 2019

Angular Universal: Adding a service worker doesn't allow specific titles for pages

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.



from Angular Universal: Adding a service worker doesn't allow specific titles for pages

No comments:

Post a Comment