Created
July 8, 2018 19:51
-
-
Save arutnik/f654cb1709a91d55fd1f4f124b462d6d to your computer and use it in GitHub Desktop.
SEO-SPA: Meta/Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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