【问题标题】:Angular Pass Input to Ionic Modal离子模态的角度传递输入
【发布时间】:2019-11-06 09:20:10
【问题描述】:

我有一个接受输入参数的组件:

export class MapComponent implements OnInit {
   @Input() options: MapOptions<any>;
}

使用 ionic ModalController 打开此模式的页面:

async pickLocationModal() {
  const modal = await this.modalController.create({
    component: MapComponent
  });
  return await modal.present();
}

另外,我在页面中存储了 mapOptions,我想传递它。

我可以将我的 mapOptions 传递给 Modal,以便组件将其作为输入吗?

【问题讨论】:

  • 你的问题根本不清楚。 modalController 是什么?是你的模态实现吗?
  • 抱歉,我使用的是 ionic,我的印象是它是内置于 Angular 中的,它让我忘记了

标签: javascript angular typescript ionic4


【解决方案1】:

我假设您使用的是 Ionic,因为这是 ionic 的 ModalController 的相同实现。

根据他们的docs,可以通过传递给componentProps

async pickLocationModal() {
  const modal = await this.modalController.create({
    component: MapComponent,
    componentProps: { // <----------
      options: ...
    }
  });
  return await modal.present();
}

【讨论】:

  • 谢谢,直到你这么说,我才意识到这是离子学。当时间限制过去时,我会将此答案标记为正确
猜你喜欢
  • 2023-04-08
  • 1970-01-01
  • 2015-02-03
  • 2019-05-27
  • 1970-01-01
  • 2021-11-30
  • 1970-01-01
  • 2023-03-21
  • 1970-01-01
相关资源
最近更新 更多