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

116
Views
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 answers
Answer question

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