Angular 6 : Dynamic Meta tag is not working when sharing page on facebook using og:description tag

标签 angular dynamic angular5 angular6 meta-tags

我想使用 API 调用在元标记中设置动态信息。当我通过检查检查时,它会显示更新的数据,但是当我在 Facebook 上分享链接时,它不会反射(reflect)更新的数据。

索引.html

  <meta name="description" content="Create and share your biography">
  <meta name="og:url" content="window.location.href"> 
  <meta name="og:title" content="TEACHERLIFE -SPANISH LESSONS">
  <meta name="og:description" content="So I’m in my classroo...">

在 component.ts 中:
import { Meta, Title } from '@angular/platform-browser';
 constructor(private metaService: MetaService,
    private meta: Meta,) {}
  ngOnInit() {
this.meta.updateTag( {name: 'og:description', content:"testdescription"});
}

最佳答案

Facebook Share 不解析 javascript,因此它只拦截 index.html 页面上的静态元数据。
请参阅 github 社区中的完整讨论。
https://github.com/jvandemo/angular-update-meta/issues/13

关于 Angular 6 : Dynamic Meta tag is not working when sharing page on facebook using og:description tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54689982/

相关文章:

angular - 如何在 Angular 2 的 UI-Router 中更改 href 生成?

Angular 2 - 在不显示 url 数据的情况下导航

c# - CacheItemUpdateCallback 中的 HttpContext.Current Null

带有 html 的 Angular-Tree-Component 样式节点

angular 5路由到相同的组件但不同的参数,不工作

jquery-ui - jquery datepicker 不显示在动态添加的输入上

java - Log4J 动态配置

html - 如何使用角 Material 表添加多个标题行

angular - 从 SafeValue 访问 @ContentChildren

Angular 6 MatPaginator 不显示表格的垫选项,也不为下一个按钮和后退按钮设置样式