I have a product catalog in Angular 7 and I would like the header to change in each product so that it has the meta data of URL, Title, Image etc... different for each product, how can this be done?
Greetings and thank you.
I have a product catalog in Angular 7 and I would like the header to change in each product so that it has the meta data of URL, Title, Image etc... different for each product, how can this be done?
Greetings and thank you.
If you can, add these imports to your code.
We declare the classes in the constructor:
Then you modify the title and the meta tag in some function:
Here I leave some links with the information: https://angular.io/guide/set-document-title https://angular.io/api/platform-browser/Meta#addtag
I have already managed to solve it, I leave the solution here.
CHANGE META TAGS
1). We import in the component that we want to update the meta the following module
two). We declare it in the constructor.
3). In the ngOnInit we declare the content of the metas.
More extensive information here: SEE MORE
CHANGE THE TITLE OF THE PAGE
1). We import the module in the components where we want to change the title.
two). We declare it in the constructor.
3). In the ngOnInit we declare the content of the title.
I hope I have been helpful, thank you.