Set or Update new Title and Meta Tag- Angular

Title

To set different “Title” on the page(head section)

import { Title} from '@angular/platform-browser';
public constructor(private titleService: Title) { }ngOnInit() {
this.titleService.setTitle("your page title");
}

Meta

To set/update different “Meta” on the page(head section)

import { Meta} from '@angular/platform-browser';
public constructor(private metaService: Meta) { }
ngOnInit() {
this.metaService.addTags([
{name: 'keywords', content: 'your keywords content'},
{name: 'description', content: 'your page description content'},
]);
}
ngOnInit() {
this.metaService.updateTag({ name: 'keywords', content: 'your updated keywords content'});
}
ngOnInit() {
this.metaService.removeTag({ name: 'keywords', content: 'your updated keywords content'});
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anil Verma

Anil Verma

22 Followers

Hi there 👋, I am Anil Verma, a full stack web developer, and JavaScript enthusiast. 👥 Ask me anything about web development. 📖 Love to read and write.