Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
Angular directive not working with ng-container

The given below code ng-if is not working as expected

if displayGroup value is D then it will print the first and Second block, did I made any mistake

<div *ngIf="(bookTravelInfo.displayGroup | uppercase) === 'A' || 'B' || 'C'  ">
  <h2>Perfect!</h2>
</div>
<div *ngIf="(bookTravelInfo.displayGroup | uppercase) === 'D'  ">
  <h2>Does not Perfect</h2>
</div>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to check bookTravelInfo.displayGroup is either 'A' or 'B' or 'C',

Use

*ngIf="['A', 'B', 'C'].includes(bookTravelInfo.displayGroup | uppercase)"

|| Logical OR operator from your *ngIf will never return false.

As the boolean result returned true when the value is neither null, nor undefined nor false as according to ToBoolean.

Hence the first <div> element still be displayed with:

*ngIf="(bookTravelInfo.displayGroup | uppercase) === 'A' || 'B' || 'C'"
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda