Go ProSign in

This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Add dynamic metadata to an Angular CLI Project

In this lesson we will create a UiService and inside that service we create some application defaults, import the Title and Meta services from @angular/platform-browser and create a function called setMetaData.

This function will set the metadata of the application based on the config parameter.

We set some defaults and define a list with tags. We then loop over the tags and invoke the updateTags method from the Meta service.

Once our service is ready we update the ProductListComponent and ProductDetailComponent to dynamically set the meta data by using the tap operator in the pipe from our Subscription.

After building and deploying the app we see that the meta data gets updated, and we can now share the app over Social Media and get rich social previews.

You must be a Member to view code