どのプロジェクトでも使用できるdatepickerコンポーネントを開発しようとしています。Ionic2を拡張してModalControllerを注入する
コンポーネントを持つNgModuleを持っていて、ionic2のすべてのコンポーネント/ディレクティブを使用できるように、IonicModuleを注入します。
@NgModule({
imports: [
CommonModule,
IonicModule.forRoot(DatePickerModule)
],
exports: [DatePickerComponent, DatePickerDirective],
entryComponents: [DatePickerComponent],
declarations: [DatePickerComponent, DatePickerDirective],
providers: [DateService, nls]
})
export class DatePickerModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: DatePickerModule
};
}
};
これらの構成要素のうちの1つは、モーダルを表示するイオンモダルコントローラを注入する。
export class MainDirective{
public static config:any;
constructor(private modalCtrl:ModalController) {
}
openModal() {
this.modalCtrl.create(DatePickerComponent
).present();
}
}
このNgModuleは別のアプリケーションにインポートされ、そのアプリケーションからopenModalを呼び出そうとしています。 これは私が何が起こることは、それがイオン-角度ライブラリからエラー未定義の「_getPortal」をスローすることです
@NgModule({
imports: [
IonicModule.forRoot(App),
DatePickerModule.forRoot(),
],
})
をインポートする方法です。 私はそれが表示するアプリを見つけることができないと推測しています。
私はforRootにACTUAL APPを渡す必要があると推測していますが、これを行う方法はわかりません。
この問題にアプローチするにはどうすればよいでしょうか?
このプロセスを説明してくれてありがとうございます。私はこれを試して、私はまだngmoduleがモーダルを表示する必要があるアプリのルートを見つけることができない同じ問題に遭遇した。 – misha130