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

0

I have a problem with ngFor because I want to enable the + button only when an item in the list is selected. But my option element 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 already tried to create the method below and use it in option , but it did not work:

liberaBtn() { this.isActive = false; }

    
asked by anonymous 15.03.2018 / 14:41

1 answer

0

Instead of the click use:

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

no ts put:

onChange(){

}
    
16.03.2018 / 21:22