我可以使用 ngIf 条件来改变单词的意思吗?

can l use ngIf condition to change mean of word?

我是 angular 和 ionic 的初学者。我正在尝试从 URL 获取数据 JSON 并且我想将来自 URL 的单词的含义更改为另一种语言。我尝试使用 ngif 来达到目的,但是没有用!

我做了什么来改变意思

<td text-right *ngIf="item?.flight.status.generic.status.text == 'scheduled';">مجدولة</td>

甚至有时我从 URL 得到 null 值,我需要用 ngif

检查它
<td text-right *ngIf="!item.flight.status.generic.status.text == 'null';">N/A</td>

同时我使用 ngfor 循环遍历数据:

    <ion-item *ngFor="let item of items" routerDirection="forward" > 
        <table>
          <tbody>
            <tr >
              <td text-right *ngIf="item?.flight.status.generic.status.text == 'scheduled';">مجدولة</td>
              <td text-right *ngIf="!item.flight.status.generic.status.text == 'null';">N/A</td>
            </tr>
          </tbody>
        </table>
      </ion-item>

创建一个 angular 管道。这就是管道的用途。因此,某些值通过某种逻辑得到 mapped/translated .. 到所需的值。 检查这个:angular pipes

您可以轻松创建自己的管道,如下所述:custom angular pipe

所以你会使用这样的东西:

<td text-right>{{item?.flight.status.generic.status.text | myPipe}}</td>

希望对您有所帮助!