ion-select load application with an option already selected in Storage

Asked

Viewed 253 times

0

I created a list in the application to which I can select an option that will be saved in the database, I would like when loading the application that the saved option already comes as selected.

Today when loading it is displayed like this:

Hoje ao carregar ele é exibido assim

I would like to start the application already load the last saved option:

inserir a descrição da imagem aqui

My code:

 <button ion-button full color="white" class="text-ddi">
<ion-select [(ngModel)]="selectddi" interface="popover"  align-left  (ionChange)="ddiSelecionado();">
  <ion-option *ngFor="let ddilista of ddilista" value="{{ddilista.codigo}}" >{{ddilista.nome}}</ion-option> 
</ion-select>

1 answer

0

How are you using [(ngModel)]="selectddi", the option selected by default will be the same where the attribute value of ion-option is equal to the content of selectddi

To put the last item in the list marked as default you just need to put the value in selectddi:

selectddi = dddlista[dddlista.length - 1];

Browser other questions tagged

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