datepicker-ionic2@2.6.0 does not work with --prod mode
Build success, but when in app datepicker is called, in console:
Error: Uncaught (in promise): Error: No component factory found for undefined. Did you add it to @NgModule.entryComponents?
Module declared in app.module.ts and page.module.ts (otherwise it does not work).
Without “–prod” works fine.
Thanks in advance for the help.
cli packages:
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.1.4
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.6.0
System:
Android SDK Tools : 25.2.5
Node : v7.10.0
npm : 4.5.0
OS : Windows 10
Your import statements are probably wrong. ngc is much more picky about this than ionic serve.
import { DatePickerModule } from 'datepicker-ionic2';
imports: [
IonicModule.forRoot(App),
DatePickerModule,
],
ionic cordova run android --prod
build success, but does not work. Without –prod works fine.
In your OP, you said that build was generating an error. Why are you saying this now?
Also: are you lazy loading pages?
Sorry, may not be so expressed.
No, the error is not an build, but a call to this datepicker in the application.
Yes. In my child-item.module.ts
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ChildItemPage } from './child-item';
import { DatePickerModule } from 'datepicker-ionic2';
@NgModule({
declarations: [
ChildItemPage,
],
imports: [
IonicPageModule.forChild(ChildItemPage),
DatePickerModule,
],
})
export class ChildItemPageModule {}
What does the import into the class ChildItemPage look like?
Edit: Actually you may not need one. The first thing I’d check is if it works if you don’t lazy load the page. That’s what the module is probably expecting. So if you can get it to compile with the page loaded into app.module.ts, then at least you’ll have a working build.
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { Http } from '@angular/http';
import { Storage } from '@ionic/storage';
import { CustomerService } from '../../providers/customer-service';
import { Customer } from '../../models/customer-model';
import { ConnectivityService } from '../../providers/connectivity-service';
import { AlertService } from '../../providers/alert-service';
import { LocalNotifications } from '@ionic-native/local-notifications';
@IonicPage()
@Component({
selector: 'page-child-item',
templateUrl: 'child-item.html',
})
export class ChildItemPage {
...
I do not know if this affects anything, but this page is also Tab Item.
You might need to import the directive there. But as I said in my edit above, the first thing I’d check is whether you can get it working in a non-lazy-loaded page.
import { DatePickerDirective } from 'datepicker-ionic2';
Literally googling trying to recreate the error to fix it.
Curses be upon my code
AaronSterling:
You might need to import the directive there. But as I said in my edit above, the first thing I’d check is whether you can get it working in a non-lazy-loaded page.
import { DatePickerDirective } from ‘datepicker-ionic2’;
I tried different options, removed lazy loading pages, it still does not work with --prod.