Toogle Select Function

-1

I have the following scenario:

I have a list of addresses that comes dynamically from the database, according to what is registered by the user.

I need to enable only one address, so when one button is activated all other ones are disabled.

changeAddress(data) {
    if (data.status_info_end === 0) {
      data.status_info_end = 1;
    } else {
      data.status_info_end = 0;
    }
  }
<div class="wrap-end" *ngFor="let data of totalend">
    <div class="wrap-inner-end-one">
      <div class="inner-header-end"> {{data.bairro_user}} - {{data.cidade_user}} - {{data.estado_user}}</div>
      <div class="central">{{data.cep_user}}</div>
    </div>
    <div class="wrap-inner-end-two">
      <span class="bt-change" [ngClass]="{'bt-changed' : data.status_info_end}" (click)="changeAddress(data)">
        <span class="round-bt" [ngClass]="{'rounded-bt' : data.status_info_end}"></span>
      </span>
    </div>
  </div>
    
asked by anonymous 31.10.2018 / 08:27

1 answer

1

Make a function to set the "status_info_end" field to 0 for all array elements. You can do this with a foreach ... Run it every time you click and only after running it you activate the element you want ....

    
31.10.2018 / 18:40