Toogle Select function

Asked

Viewed 23 times

-1

I have the following scenario:

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

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

inserir a descrição da imagem aqui

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>
inserir a descrição da imagem aqui

1 answer

1

Do a function to set the "status_info_end" field to 0 of 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....

Browser other questions tagged

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