首页 > 解决方案 > 在 Angular 通用 API 调用后 JSON-LD 不起作用

问题描述

我正在使用 Angular 7 和 Angular 通用,并将使用 JSON-LD 实现 Google 结构化数据。

JSON-LD 不是静态的,需要通过 API 获取值。顺便说一句,静态 JSON-LD 效果很好,但在 API 调用之后,它就不起作用了。

<ngx-json-ld [json]="schema"></ngx-json-ld>
this._appService.getAPI(`${this.storyApiUrl}`).subscribe(result => {
    const json = {
          '@context': 'https://schema.org/',
          '@type': 'Article',
          'headline': result.meta.seo.title,
          'name': result.meta.seo.author,
          'datePublished': result.data.posted_on,
          'dateModified': result.data.posted_on,
       ...
    }
...

请帮我!

标签: jsonangularangular-universaljson-ld

解决方案


推荐阅读