The blog is all about Meta Tags. In a simple way meta tags are used for search engine optimization to describe the page content. Meta tags always inside the <head>
section.
We are going to set the most common three header meta description
, title
and tag content
dynamically.
Import the predefined Meta Service in your component :
import { Meta, Title } from '@angular/platform-browser';
Inject the Service in Constructor :
constructor(private title: Title, private meta: Meta) {}
Add title
and meta tag
in ngOnInit()
using setTitle
and updateTag
:
ngOnInit() { this.title.setTitle('Angular Overview'); this.meta.updateTag({ name:'author',content:'angulartpoint.com'}); this.meta.updateTag( { name:'keyword', content:'angular overview, features' }); this.meta.updateTag( { name:'description', content:'It contains overview of angular application' }); }
Happy coding!!!
Top comments (0)