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

0

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

Today loading it looks like this:

IwouldliketostarttheapplicationwhenIloadthelastsavedoption:

Mycode:

<buttonion-buttonfullcolor="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>

    
asked by anonymous 18.10.2018 / 19:03

1 answer

0

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

To put the last item in the list marked as default you only have to put the value in selectddi :

selectddi = dddlista[dddlista.length - 1];
    
20.10.2018 / 04:31