Ionic 4 - Pass Data BACK from Modal

后端 未结 3 516
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 19:03

I\'m trying to create a modal window, pass it an array of objects, have a user select one object from that array, and then have my modal pass back the object they\'ve select

3条回答
  •  半阙折子戏
    2020-12-15 19:38

    Below code is working for me.

    async openUserModal() {
        const modal = await this.modalCtrl.create({
          component: UserModalComponent,
          componentProps: { users: this.users },
        });
    
        modal.onDidDismiss()
          .then((data) => {
            const user = data['data']; // Here's your selected user!
        });
    
        return await modal.present();
      }
    

提交回复
热议问题