我正在開發一個醫療網站,當藥物的數量爲< 50時,我想在medicament.component.HTML的頁面上顯示警報。 我這樣做:Angular 2 TypeError:無法讀取未定義的屬性'toUpperCase'
<span *ngFor="let medicament of medicaments" >
<span *ngIf="{{medicament.quantity}} < 50">
<div class="callout callout-danger lead">
<h4>Alert!</h4>
<p>Vous devez charger le stock de medicaments {{medicament.nom}}
de type {{medicament.type}} </p>
</div>
</span></span>
但我不知道爲什麼它不工作,錯誤的是:
> Unhandled Promise rejection: Template parse errors:
TypeError: Cannot read property 'toUpperCase' of undefined ("<span
*ngIf="medicaments">
<span *ngFor="let medicament of medicaments" >
<span [ERROR ->]*ngIf="{{medicament.quantity}} < 50">
<div class="callout callout-danger lead">
"): [email protected]:18
Can't bind to '*ngIf' since it isn't a known property of 'span'.
("<span *ngIf="medicaments">
<span *ngFor="let medicament of medicaments" >
<span [ERROR ->]*ngIf="{{medicament.quantity}} < 50">
<div class="callout callout-danger lead">
"): [email protected]:18
在這串你嘗試使用toUpperCase?你可以提供你的控制器或任何其他的JS? – Sandwell