Meta tag, Open Graph script generated

Asked

Viewed 27 times

0

Next the metatag works normal when added in the . html, but when using the same metatag in the angular Meta is not recognized.

someone has already gone through this trouble to give a helping hand?

    import { Meta } from '@angular/platform-browser';
    constructor(private meta: Meta){}
    ngOnInit(): void {
    this.meta.addTag({name: 'og:type', content: 'website'});
        this.meta.addTag({name: 'og:locale', content: 'pt_BR'});
        this.meta.addTag({name: 'og:url', content: 'https://www.exemplo.com.br'});
        this.meta.addTag({name: 'og:title', content: 'exemplo.com.br'});
       let metaEl: HTMLMetaElement = this.meta.getTag('name= "og:title"');
       console.log(metaEl);
       console.log(metaEl.name);
       console.log(metaEl.content);
}

console response.log:

app.component.ts:70 <meta property="og:title" content="exemplo.com.br">​
app.component.ts:71 og:title
app.component.ts:72 exemplo.com.br
core.js:19775 Angular is running in the development mode. Call enableProdMode() to enable the production mode.
  • If you’re trying to use Angular meta tags for SEO, forget it, it doesn’t work! It will only work if you use Universal Angular, which is an SSR (Server Side Rendering). link

  • @Gesielrosa truth already tested it, I will implement it later because it has some details that can only be loaded when it finds the browser, and tbm want to test his performance because it uses Node ne

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.