Add meta description based on current page in Angular

896 Views Asked by At

Hi I'm using Angular 13 to build a small website. The project contains 5 components and each component have their own meta-tags and descriptions. When I am switching from one component to another and try to "view the source code" I want to see the meta-tag and description of that component, but its showing only the meta-type and description of Index.html file.

below is my sample code for the child component for which I want to see the meta title and meta description but it is not working. Can any one please suggest a solution.

index.html

<head> 
    <title> Title here  </title> 
    <meta data-rh="true" name="description" content=" Description is here"/> 
</head> 
 

Typescript file for child component

export class NoticeComponent implements OnInit { 
    ngOnInit() {
        this.meta.updateTag({name:'keywords',content:'Title-1 here'}); 
        this.meta.updateTag({name:'description',content:'Description-1 is here '}); 
    }
}
0

There are 0 best solutions below