2017-10-16 38 views
1

我想ngIf的使用情况,以显示信息工作控制台:NgIf不未定义

console.log(this.airplaneType === undefined); 

并且它返回true。

我正在使用Angular 4.4.4。

+0

请使用==代替===,并使用单引号'undefined' – Amit

+0

它按预期工作。 “airplaneType”的数据类型是什么? – Faisal

+0

我用==试过,它没有帮助。 – Pawel

回答

0

我来到了一个解决方案。我以这种名义控制了这个形式。因为有冲突

0

做这样的:

<div [class.error]="airplaneType === undefined"> 
    Choose correct airplane from the list! 
</div>