How to use OR condition in ngIf in angular?

990 views angular
4

Suppose I have the logic inside the component.ts:

 selectInput(event) {
    let selected = event.target.value;

    if (selected == "firm") {
      this.isNameSelected = true;
    } else if(selected == "consignment") {
      this.isNameSelected = false;
      this.labelForCP=true;
    }
    else{
      this.tash=true;
       this.isNameSelected = false;
        this.labelForCP=false;
    }
  }

And in my html i have:

<div class="form-group col-md-4" *ngIf="!isNameSelected">

i tried to combine *ngIf="!isNameSelected || tash" but I am getting the error in console as i cant apply this kind of method. I want the condition if anyone of the condition is true(OR condition) it must enter inside the section.

answered question

1 Answer

4

Its simple as normal if condition, below one should work

<div class="form-group col-md-4" *ngIf="isNameSelected === false || otherCondition === true">

posted this

Have an answer?

JD

Please login first before posting an answer.