簡體   English   中英

Ionic 3中斷數據和顯示或有角行李箱選項

[英]Ionic 3 break data and show or angular trunk option

我正在從api獲取一些數據,但是它們是一些措辭,它們在單個字符串中。 我需要分開給他們看。 它是如何在控制台中出現的:

在此處輸入圖片說明

我想在我的應用程序中顯示如下:

在此處輸入圖片說明

這樣已經在其他移動應用程序中顯示了。 但我想知道它將如何處理離子角。

我就是這樣顯示措辭的。

.ts
 this.wording = this.res[0].policywording;

 .html
 <div *ngIf="wording">{{wording}}</div>

並且輸出與控制台中的輸出相同,但未按順序顯示,我想像我附加的那樣顯示它。 我認為通過樹干是可能的,但不知道使用它的病情如何。

您必須分解這些數據。 像這樣:

ts:

this.displayData = [];
if (this.wording) {
  const policies = this.wording.split('|').filter(w => w !== '');
  this.displayData = [];
  policies.forEach((policy) => {
    const splited = policy.split('=');
    const displayPolicy = {name: splited[0], value: splited[1]};
    this.displayData.push(displayPolicy);
  });
}

.html:

<div *ngIf="displayData && displayData.length > 0">
 <div *ngFor="let policy of displayData">{{policy.name:}} {{policy.value}}</div>
</div>
<div *ngIf="!displayData || displayData.length === 0">No Data available</div>

暫無
暫無

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

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