简体   繁体   English

Angular 4 * ngif有条件检查

[英]Angular 4 *ngif conditional check

I need to check a value for negative 1 that I use for failure but I don't want to display that value. 我需要检查用于失败的负1值,但我不想显示该值。 Instead I want to display either "N/A" or "--" but I am new to angular and not sure how. 相反,我想显示“ N / A”或“-”,但是我对角度是陌生的,不确定如何。 My material table is listed below. 我的材料表在下面列出。 Any help would be appreciated. 任何帮助,将不胜感激。

<div>
   <ng-container matColumnDef="Milliseconds">
      <mat-header-cell *matHeaderCellDef mat-sort-header> Milli seconds </mat-header-cell>
  <mat-cell *matCellDef="let latency"> {{latency.Milliseconds}} </mat-cell>
   </ng-container>
</div>

Thanks in advance 提前致谢

您可以使用三元运算符执行此操作

<mat-cell *matCellDef="let latency">{{ latency.Milliseconds === -1 ? '--' : latency.Milliseconds }}</mat-cell>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM