Angular 如何在离子选择上获得多个值

Angular 如何在离子选择上获得多个值,angular,firebase,ionic-framework,firebase-realtime-database,ionic3,Angular,Firebase,Ionic Framework,Firebase Realtime Database,Ionic3,我正在尝试使用离子选择和离子选项创建一个简单的创建组页面 我的html <ion-item> <ion-label>Select Friends</ion-label> <ion-select [(ngModel)]="selectedFriendsArray" multiple="true" cancelText="cancel" okText="ok"> <ion-option *ngFor="let friend of

我正在尝试使用离子选择和离子选项创建一个简单的创建组页面

我的html

<ion-item>
  <ion-label>Select Friends</ion-label>
  <ion-select [(ngModel)]="selectedFriendsArray" multiple="true" cancelText="cancel" okText="ok">
    <ion-option *ngFor="let friend of myFriendsArray; let i = index" value="{{friend.$value}}" selected="false">{{friend.fullName}} (@{{friend.$key}})</ion-option>
  </ion-select>
</ion-item>
当用户选择要添加的好友时,selectedFriendsArray会像这样登录控制台

0: "4TV40AiZb6a9IPNjhSGM7Q15EPz1"
1: "XKCk1bE0DvUKFTPTpFebkxLGI4J2"
2: "yICGapOLBaZae7EgdiRlGA4lmPF3"
1:{$value: "4TV40AiZb6a9IPNjhSGM7Q15EPz1", userName: "test1"}
2:{$value: "XKCk1bE0DvUKFTPTpFebkxLGI4J2", userName: "test2"}
3:{$value: "yICGapOLBaZae7EgdiRlGA4lmPF3", userName: "test4"}
但我不想要这样,我想要的就是这样

0: "4TV40AiZb6a9IPNjhSGM7Q15EPz1"
1: "XKCk1bE0DvUKFTPTpFebkxLGI4J2"
2: "yICGapOLBaZae7EgdiRlGA4lmPF3"
1:{$value: "4TV40AiZb6a9IPNjhSGM7Q15EPz1", userName: "test1"}
2:{$value: "XKCk1bE0DvUKFTPTpFebkxLGI4J2", userName: "test2"}
3:{$value: "yICGapOLBaZae7EgdiRlGA4lmPF3", userName: "test4"}
因为我希望在我的数据库中有这样的数据结构

组>组ID>成员>成员ID:“成员用户名”

我真的很喜欢ion选项,但它只将value=”“输入写入数组,我该怎么做

谢谢你的阅读,请帮助我

您可以使用
值“构建”所需的对象:

<ion-item>
  <ion-label>Select Friends</ion-label>
  <ion-select [(ngModel)]="selectedFriendsArray" multiple="true" cancelText="cancel" okText="ok">
    <ion-option *ngFor="let friend of myFriendsArray; let i = index" value="{{friend.$value}}" selected="false" (ionSelect)="friedFun(friend)">{{friend.fullName}} (@{{friend.$key}})</ion-option>
  </ion-select>
</ion-item>
<ion-option *ngFor="let friend of myFriendsArray; let i = index" 
  [value]="{$value: friend.$value, userName: friend.userName}" selected="false">
  {{friend.fullName}}
</ion-option>

{{friend.fullName}

它不起作用。我不知道为什么。。我应该用那个myObj吗?