I am trying to develop a datepicker component that can be used for any project.
I have an NgModule that has components and I inject IonicModule in to it so it can use all the components/directives of ionic2.
@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
};
}
};
One of the components injects ionic modal controller to display a modal.
export class MainDirective{
public static config:any;
constructor(private modalCtrl:ModalController) {
}
openModal() {
this.modalCtrl.create(DatePickerComponent
).present();
}
}
This NgModule is imported in to another App and from that app I am trying to call openModal. This is how I import
@NgModule({
imports: [
IonicModule.forRoot(App),
DatePickerModule.forRoot(),
],
})
What happens is that it throws an error '_getPortal' of undefined from ionic-angular library. I am guessing that it can't find the app to display to.
I am also guessing that I need to pass to forRoot the ACTUAL APP that will be working but I have no idea how to do this.
What would be the best way to approach this problem?