Handling Page Titles in Angular

Netanel Basal
Netanel Basal
Published in
May 17, 2022

--

Starting from version 14, Angular adds the option of setting the page title through the router. We can set the title property in our route definition:

There are times when a dynamic title is needed. For example, we might want to show a todo’s title on a todo page. This can be accomplished by passing an injectable that implements a resolver:

We would also like the company name to appear before each title in the application. Luckily, we can provide a custom title strategy and do it automatically for every route:

Follow me on Medium or Twitter to read more about Angular and JS!

--

--

A FrontEnd Tech Lead, blogger, and open source maintainer. The founder of ngneat, husband and father.