【发布时间】:2021-07-29 09:22:54
【问题描述】:
我在ng-container 中添加ngIf 条件,如果条件满足则display the component
我面临的问题是我收到错误
This condition will always return 'false' since the types 'boolean' and 'string' have no overlap.
当我将条件设置为(当我使用not operator after &&)时
<ng-container *ngIf="data.dataClass === 'Dokes'
&& !data.dataSubclass === 'Land'"> ------------------> NOT OPERATOR
但是当我删除 && !data.dataSubclass === 'Land' 中的! 运算符时,代码可以正常工作
我不知道为什么它给了我这个错误。我想将! 运算符添加为I want to display component when data.dataSubclass is not equal to 'Land'
.html 文件
<div>
<ng-container *ngIf="data.dataClass === 'Dokes'
&& !data.dataSubclass === 'Land'">-----------------------------> ERRORRR
!----- BELOW IS THE COMPONENT TO DISPLAY IF ABOVE CONDITION IS TRUE---------!
<money-property name="Pika" [model]="data.pika"
[editMode]="!!dataEditService.editMode">
<dl>
<dd *ngFor="let d of data.pika; index as i">
<edit-link dataClass="Dokes"
[(selectedElement)]="data.pika[i]" [editMode]="!!dataEditService.editMode"></edit-link>
</dd>
</dl>
</money-property>
</ng-container>
</div>
【问题讨论】:
标签: html angular typescript angular-ng-if