Import lazy component on sidenav menu


#1

My app is using lazy loading but I have components loaded in app.module becase I need them anyway by default but most of them are loaded on different pages/components.

This is side-menu.html:

<ion-content>
  <ion-list>
    <ion-item>
      <login></login>
    </ion-item>
    <ion-item>
      <language-change></language-change>
    </ion-item>
  </ion-list>
</ion-content>

login is loaded by default because the user will have to login always so this component works on the side menu.

language-change is only loaded when I need it and it works on other pages but not here. This is side-menu.module:

import { NgModule } from "@angular/core";
import { IonicPageModule } from "ionic-angular";
import { SideMenuPage } from "./side-menu";
import { LanguageChangeComponentModule } from "../../components/language-change/language-change.module";

@NgModule({
    declarations: [SideMenuPage],
    imports: [
        IonicPageModule.forChild(SideMenuPage),
        LanguageChangeComponentModule
    ],
    exports: [SideMenuPage],
    entryComponents: [SideMenuPage]
})
export class SideMenuPageModule { }

language-change.module:

import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { LanguageChangeComponent } from './language-change';

@NgModule({
    declarations: [LanguageChangeComponent],
    imports: [
        IonicModule
    ],
    exports: [LanguageChangeComponent],
    entryComponents: [LanguageChangeComponent]
})
export class LanguageChangeComponentModule { }

I got the classic

‘language-change’ is not a known element