gpt4 book ai didi

Angular 2 类型错误 : Cannot read property 'toUpperCase' of undefined

转载 作者:搜寻专家 更新时间:2023-10-30 21:14:48 25 4
gpt4 key购买 nike

我正在开发一个医疗网站,我想在药物数量 < 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">

关于 Angular 2 类型错误 : Cannot read property 'toUpperCase' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43514523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com