0

我需要用一些 HTML 标签来渲染 JSON 对象,

组件看起来像

import { Component, OnInit, } from '@angular/core';
import { BiblioService } from './biblio.service';

@Component({
selector: 'my-bibo',
templateUrl: 'biblio.component.html'
  })
  export class BiblioComponent implements OnInit {
   constructor(private _BiblioService: BiblioService) {
   this._BiblioService = _BiblioService
     }
    public index: any[] = [];
 ngOnInit() {
  this._BiblioService.getBiblio()
    .subscribe(index => this.index = index);
}
  }

模板如下所示:

 <h1 data-animate="fadeIn"> {{index["hero-region"]["hero-headline"] </h1>

输出看起来像

— Samuel Backett in <em>Proust</em>, 1930.

整个 JSON 文件看起来像

[{
  "dc.rights": "xxxxxxxxxxxxx",
  "hero-region": {
    "hero-headline": "xxxxxxxxxxxxxx",
    "hero-headline-sub": "— Samuel Backett in <em>Proust</em>, 1930."
  }
}]

什么是最好/最简单的解决方案?

4

0 回答 0