Angular 如果字符串在';这是一个循环

Angular 如果字符串在';这是一个循环,angular,angular-material,Angular,Angular Material,正在尝试获取我的字符串值,而不是在Ng if为false时显示。我读到了在字符串值上,应该使其返回false,但无论如何它都只是在进行。我想这可能是因为我没有正确地从ngfor获取变量,但我不确定 我尝试了label=“”,它也做了同样的事情,还尝试了label.tostring()='' {{label}} 我的预期结果是它返回false并且不确定mat芯片 谢谢大家这方面的指令是*ngIf=“!label”而不是ng if=“!label”。 和!标签通常为假 此指令为*ngIf=“!l

正在尝试获取我的字符串值,而不是在Ng if为false时显示。我读到了在字符串值上,应该使其返回false,但无论如何它都只是在进行。我想这可能是因为我没有正确地从ngfor获取变量,但我不确定

我尝试了label=“”,它也做了同样的事情,还尝试了label.tostring()=''


{{label}}
我的预期结果是它返回false并且不确定mat芯片


谢谢大家

这方面的指令是
*ngIf=“!label”
而不是
ng if=“!label”
。 和
!标签
通常为假

此指令为
*ngIf=“!label”
ng if=“!label”
。 和
!标签
通常为假
根据这位官员的说法

您刚刚犯了一个语法错误,您应该在没有
-
的情况下使用它,并在开头使用
*
,就像这样
*ngIf
检查下面的示例

<mat-chip-list *ngFor="let label of testValue2">
           <mat-chip *ngIf="!label">{{label}}</mat-chip>
</mat-chip-list>
如果
*ngIf
else
ng template
上,还有另一种语法

<mat-chip-list *ngFor="let label of testValue2">
  <ng-template [ngIf]="!label" [ngIfElse]="secondOption" ]>
    <mat-chip>{{label}}</mat-chip>
  </ng-template>
  <ng-template #secondOption>
    <mat-chip>Second Option</mat-chip>
  </ng-template>
</mat-chip-list>

{{label}}
第二种选择

根据这位官员的说法

您刚刚犯了一个语法错误,您应该在没有
-
的情况下使用它,并在开头使用
*
,就像这样
*ngIf
检查下面的示例

<mat-chip-list *ngFor="let label of testValue2">
           <mat-chip *ngIf="!label">{{label}}</mat-chip>
</mat-chip-list>
如果
*ngIf
else
ng template
上,还有另一种语法

<mat-chip-list *ngFor="let label of testValue2">
  <ng-template [ngIf]="!label" [ngIfElse]="secondOption" ]>
    <mat-chip>{{label}}</mat-chip>
  </ng-template>
  <ng-template #secondOption>
    <mat-chip>Second Option</mat-chip>
  </ng-template>
</mat-chip-list>

{{label}}
第二种选择

使用
*ngIf
,而不是
ng if
。使用
*ngIf
,而不是
ng if