我正在开发一个医疗网站,当药物数量小于50时,我想在medicament.component.HTML页面中显示警报。我是这样做的:
<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">
"): MedicamentComponent@26: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">
"): MedicamentComponent@26:18
您不应该{{ }}
在ngIf中使用插值;它期望一个表达式:
<span *ngIf="medicament.quantity < 50">
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句