Skip to content

Instantly share code, notes, and snippets.

@arutnik
Created July 8, 2018 19:51
Show Gist options
  • Select an option

  • Save arutnik/f654cb1709a91d55fd1f4f124b462d6d to your computer and use it in GitHub Desktop.

Select an option

Save arutnik/f654cb1709a91d55fd1f4f124b462d6d to your computer and use it in GitHub Desktop.
SEO-SPA: Meta/Title
import { Component, OnInit } from '@angular/core';
import { Title, Meta } from '@angular/platform-browser';
//An example of a component setting title and description tags
@Component({
selector: 'app-about-me',
template: `
<p>This page is about me!</p>
`,
styleUrls: ['./about-me.component.scss']
})
export class AboutMeComponent implements OnInit {
constructor(private titleService: Title,
private metaTagService: Meta) { }
ngOnInit() {
this.titleService.setTitle("My App: About me");
this.metaTagService.updateTag({name: 'description', content: "I'm a developer who writes sometimes."});
//TODO: Make Other top-level components do this so the above content doesn't get stuck there!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment