Ion-select problem


#1

I have an ion select with a list of users, i want to add a button to redirect me to other component.
It always throw me an error of undefined _id(user)

 <ion-select interface="popover" [ngModel]="selectedUser._id" (ngModelChange)="selectUser($event)">

    <ion-option *ngFor="let user of users" [value]="user._id">
      <ion-content class="stateUser">
        <a *ngIf="user?.isConnected">ON</a>
        <a *ngIf="!user?.isConnected">OFF</a>
      </ion-content>{{ getUserNickname(user) }} </ion-option>
  </ion-select>
</ion-item>

So i want to add on my options something like this


  <button (click)="openConfig()" ">
       <ion-icon class="heart-img" name="add-circle" color="danger">Open Config</ion-icon>
     </button>

#2

Hello,
whatever._id is not defined or at the time you call it not defined. Take a look to your lifecyle in ts.

Otherwise work around with wrap *ngFor in your html in an element with *ngIf=‘users’ to take care that users is alive… Maybe your [value]=*user._id" throws the errror.

By the way. Imho Elvis is dead.

Best regards, anna-liebt

Ps: How _id looks in .ts?


#3

My problem that i want to add a button, that will not take the _id just a clickable option that will redirect me.


#4

Hello,
as I can see, your button has no _id anywhere. In this case the button should not responsible for that kind of error.

Best regards, anna-liebt