Ionic version: (check one with "x")
[ ] 1.x
[ ] 2.x
[x] 3.x
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
I've a component, trying to lazy load, i get error No provider for Token LZYCMP.
Other components work fine. Not sure why this component has issue. When i try not to lazy load this component, everything works fine.
Related code:
base.modal.component.module.ts
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { CommonModule } from '@angular/common';
import {BaseModalComponent} from "./modal.page";
@NgModule({
declarations: [BaseModalComponent],
imports: [
CommonModule,
IonicModule
],
// schemas: [CUSTOM_ELEMENTS_SCHEMA],
exports: [BaseModalComponent]
})
export class BaseModalComponentModule { }
base.modal.component.ts
export interface ModalComponentData {
id?: string,
title: string,
text: string,
hint?: string,
bgcolor?: string,
icon?: string,
buttons?: any,
shareable?: boolean,
actions?: any,
isRead?: boolean,
}
@IonicPage()
@Component({
selector: 'modal-component',
templateUrl: 'modal.page.html',
})
export class BaseModalComponent {
@Input() public info: ModalComponentData;
@Input() public hasImage: string;
@Input() public controlDismiss: boolean;
@Output() public action = new EventEmitter<any>();
@Output() public image = new EventEmitter<any>();
@Output() public dismiss = new EventEmitter<any>();
media: SafeUrl;
today = new Date().toLocaleDateString('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric'
});
constructor(navParams: NavParams,
private photo: BrowsePhoto,
private events: EventService,
private viewCtrl: ViewController) {
let payload = <any>navParams.get('info');
if (!payload) {
throw new Error('BaseModalComponent must be called with info as payload.');
}
this.info = <ModalComponentData>payload;
}
onAction(index:number, button?:Object) {
if (button) {
if (!button.hasOwnProperty('id')) {
this.onDismiss();
}
let payload: any = Object.assign({index: index}, button);
this.action.emit(payload);
} else {
this.onDismiss();
}
}
onImage() {
this.photo.pickImage().then(base64 => {
this.media = <string|SafeUrl>base64;
this.image.emit(base64);
}, err => this.events.notify('There was an error processing this photo.'));
}
onDismiss() {
if (this.controlDismiss) {
this.dismiss.emit(true);
} else {
this.viewCtrl.dismiss();
}
}
}
I'm guessing this is caused by there not being any IonicPageModule.forChild() in the module.
Hello, thanks for using Ionic! Would you be able to make a repo we could use to reproduce this issue? @rapropos IonicPageModule does have forChild. Until the last patch release though we had IonicModule.forChild in the generators which was wrong (but is now fixed).
@jgw96 perhaps I am not seeing something that is actually there, but I do not see an IonicPageModule.forChild() in the module code posted in the OP, and that's what I think is the cause of the problem.
Ahhh, sorry i was confused. Good spot @rapropos . @kodeine would you mind taking a look at this article and seeing if that helps you? Thanks!
Hello all! As it seems it has been a while since there was any activity on this issue i will be closing it for now. Feel free to comment if you are still running into this issue. Thanks for using Ionic!
I know this is closed, just wanted to confirm the fix works for me.
My page module had simply 'IonicPageModule' in the imports, and i got this error message for no token.
As soon as I changed it to
imports: [
IonicPageModule.forChild(NotificationsPage),
it was fixed
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
Ahhh, sorry i was confused. Good spot @rapropos . @kodeine would you mind taking a look at this article and seeing if that helps you? Thanks!