Skip to content

Instantly share code, notes, and snippets.

@talkingdotnet
Created December 4, 2017 06:59
Show Gist options
  • Save talkingdotnet/19c0b1f121b30595d65145003fe30110 to your computer and use it in GitHub Desktop.
Save talkingdotnet/19c0b1f121b30595d65145003fe30110 to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
import { Meta } from '@angular/platform-browser';
@Component({
selector: 'my-app',
templateUrl: './home.html',
})
export class HomeComponent {
constructor(private meta: Meta) {
this.meta.addTag({ name: 'description', content: 'How to use Angular 4 meta service' });
this.meta.addTag({ name: 'author', content: 'talkingdotnet' });
this.meta.addTag({ name: 'author', content: 'Other Author' }, true);
const author = this.meta.getTags('name=author');
console.log(author[0]); //<meta name="author" content="talkingdotnet">
console.log(author[1]); //<meta name="author" content="Other Author">
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment