【问题标题】:Material date picker is not working within ion-modal材料日期选择器在离子模态中不起作用
【发布时间】:2022-06-15 18:32:24
【问题描述】:

当我们在离子模式弹出窗口中调用材料日期选择器时,以下内容不起作用。

在主页中,我有这段代码可以打开模态控制器。

const modal = await this.modalController.create({
  component: TestPage,
  cssClass: 'my-custom-modal-css1',
  swipeToClose: true,
  // breakpoints: [0, 0.2, 0.5, 1],
  // initialBreakpoint: 0.2,
  presentingElement: await this.modalController.getTop(),
});

return await modal.present();
In the TestPage, i have included this html

      <mat-card class="demo-inline-calendar-card">
      <mat-calendar [(selected)]="selected"></mat-calendar>
    </mat-card>
    <p>Selected date: {{selected}}</p>

它在测试页中不起作用,但在主页中起作用。

没有办法解决这个问题..

解决方案:

我已修复垫子日历显示问题。 我已经导入了模块,但它需要在 app 模块中声明组件 ts,如下所示:

  declarations: [TestPage], 
  entryComponents: [TestPage],

一旦包含它,在模式中显示的日历内联。

希望对某人有所帮助。

【问题讨论】:

  • 你为什么在 ionic 中使用 Material UI?
  • 虽然@NajamUsSaqib 说的是真的,但大多数情况下,当您从离子模式打开选择器时,您需要在应用程序模块中导入 mat 日历而不是启动页面模块(因此导入应该是全局的为了在模态中使用)
  • @MostafaHarb 我也在应用程序模块中导入了 mat 日历,但它不起作用。但是当我使用输入类型=日期时,它正在工作。但是没有一个材料日历或自定义日历不起作用
  • @MostafaHarb 一天后我已经修复了 mat-calendar 显示问题。我已经导入了模块,但它需要在 app 模块中声明组件 ts,如下所示:@NgModule({ declarations: [TestPage], entryComponents: [TestPage],

标签: angular ionic-framework ionic5 angular11


猜你喜欢
  • 1970-01-01
  • 2021-01-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多