簡體   English   中英

如何在Angular 5中顯示來自Json Mapper的數據?

[英]How to display Data from Json Mapper in Angular 5?

我是使用TypeScript的Angular5的初學者,我試圖找到如何從JSON顯示數據的方法。實際上,我有一個用Java創建的API。 在我的Angular中,我創建了一個像這樣的JSON Mapper:

我來自Java的Json看起來像這樣:

  [ { "type": "SERVICE", "nom": "aide-services", "equipes": [ { "nom": "IKKI" } ], "serveurs": [ { "id": 2, "nom": "vtcint2", "ip": "10.10.25.45", "indicateurs": { "BUILDDATE": "2018-01-03T06:02:05Z", "STATUS": "OK", "VERSION": "2.2.0-SNAPSHOT" } } ] 

目前,我只能顯示以下應用程序中的類型和{{app.type}} {{app.nom}{{app.type}} {{app.nom}但是,當我想顯示例如來自Servurs的數據時,我無法{{app.serveurs}}我的HTML顯示[Object object]請問如何解決呢? 提前致謝

<code>

interface Applications {
  type : string;
  nom : string;
  equipes: Equipe[];
  serveurs: Serveur[];
}

interface Equipe {
  nom : string;
}

interface Serveur {
  id: number;
  nom: string;
  ip: string;
  indicateurs: Indicateurs;
}

interface Indicateurs {
  BUILDDATE: Date;
  STATUS: string;
  VERSION: string;
}

</code>

我解決了我的問題。 我只需要這樣迭代:

 <div *ngFor="let s of apps">{{s.serveurs.VERSION 

這只是為可能遇到像我一樣的問題的人說明解決方案的示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM