Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Angular 2 TypeError: no se puede leer la propiedad 'toUpperCase' de undefined

Estoy desarrollando un sitio web médico , quiero mostrar una alerta en la página de medicment.component.HTML cuando la cantidad de medicamentos sea < 50 . Hice esto :

 <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>

Pero no sé por qué no funciona, el error es:

 > 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
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

No debe usar la interpolación {{ }} en ngIf; espera una expresión:

 <span *ngIf="medicament.quantity < 50">
over 4 years ago · Santiago Trujillo Report

0

ngIf ya está en el contexto angular, lo que significa que debe eliminar los corchetes {{}}

over 4 years ago · Santiago Trujillo Report

0

Aquí en sus registros puede ver el punto de error:

 <span [ERROR ->]*ngIf="{{medicament.quantity}} < 50">

y es porque está usando una expresión en una propiedad donde no debería. Solo necesita usar la propiedad que está comparando:

 <span *ngIf="medicament.quantity < 50">
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!