How do I release my ' + ' button only when selecting an item from the list?

Asked

Viewed 46 times

0

I have a problem in ngFor, because I want to enable the + button only when an item in the list is selected. But my widget option does not accept Event bind (click). Can you help me?

<div class="container"> <div class="row"> <button (click)="setItem()">Items</button> <select class="custom-select"> <option *ngFor="let item of itemSelecionado">{{ item }}</option> </select> </div> </div> <div class="container"> <button class="btn btn-primary" type="button" [disabled]="isActive">+</button> </div>

itemSelecionado = [];
items = ['Teste A', 'Teste B', 'Teste C', 'Teste D', 'Teste E'];
isActive = true;

setItem(){
  this.itemSelecionado = this.items;
  console.log(this.itemSelecionado);
}

I have already tried to create the method below and use it in option, but it didn’t work out:

liberaBtn() { this.isActive = false; }

  • What will this button do? Add more fields ?

1 answer

0

Instead of click use:

 <select class="custom-select" (change)="onChange($event.target.value)">
      <option *ngFor="let item of itemSelecionado">{{ item }}</option>
    </select>

in ts place:

onChange(){

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.