Angular Meta
JS
S
JavaScriptFor example, this blog would have a different title, description and image for each post. To ensure each post gets the correct information we can use the Meta service which allows us to dynamically add and update the meta tags on the page.
1export class AppComponent {
2 constructor(meta: Meta) {
3 // Twitter Markup
4
5 this.meta.updateTag({ name: 'twitter:card', content: 'summary_large_image' });
6 this.meta.updateTag({ name: 'twitter:site', content: '@TheAngularGuru' });
7 this.meta.updateTag({ name: 'twitter:title', content: 'Article title' });
8 this.meta.updateTag({ name: 'twitter:description', content: 'Article description' });
9 this.meta.updateTag({ name: 'twitter:image', content: 'image.jpg' });
10 }
11}Created on 9/5/2019