Angular 6:使用 og:description 标签在 Facebook 上共享页面时,动态元标签不起作用

Dha*_* G. 6 dynamic meta-tags angular angular5 angular6

我想使用 API 调用在元标记中设置动态信息。当我通过检查进行检查时,它将显示更新的数据,但当我在 Facebook 上共享链接时,它不会反映更新的数据。

\n\n

索引.html

\n\n
  <meta name="description" content="Create and share your biography">\n  <meta name="og:url" content="window.location.href"> \n  <meta name="og:title" content="TEACHERLIFE -SPANISH LESSONS">\n  <meta name="og:description" content="So I\xe2\x80\x99m in my classroo...">\n
Run Code Online (Sandbox Code Playgroud)\n\n

在组件.ts中:

\n\n
import { Meta, Title } from \'@angular/platform-browser\';\n constructor(private metaService: MetaService,\n    private meta: Meta,) {}\n  ngOnInit() {\nthis.meta.updateTag( {name: \'og:description\', content:"testdescription"});\n}\n
Run Code Online (Sandbox Code Playgroud)\n

小智 -2

import { Meta } from '@angular/platform-browser';

constructor(private meta: Meta) {}

ngOnInit() {
  this.meta.updateTag(
     {name: 'twitter:title', content:'Front-end Web Development'},
     `name='twitter:title'`
   );
}
Run Code Online (Sandbox Code Playgroud)