Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'forChild' does not exist on type 'typeof IonicModule'

I'm using the ionic cli to generate the page using this command

ionic generate page login
ionic g page login

then i get this error in browser

Typescript Error
Property 'forChild' does not exist on type 'typeof IonicModule'.
E:/workspace/Ionic/myApp/src/pages/login/login.module.ts
imports: [
  IonicModule.forChild(Login),
],

also creating 4 items in login folder.

1.login.html
2.login.ts
3.login.module.ts
4.login.scss

any body can solve this. here is login.module.ts

import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { Login } from './login';

@NgModule({
  declarations: [
    Login,
  ],
  imports: [
    IonicModule.forChild(Login),
  ],
  exports: [
    Login
  ]
})
export class LoginModule {}

if i remove this line , app works fine.

 IonicModule.forChild(Login),
like image 905
Nadeem Yousaf Avatar asked Apr 06 '17 07:04

Nadeem Yousaf


1 Answers

There is

IonicModule.forRoot(MyApp).

Github link here.

export class IonicModule {

/**
 * Set the root app component for you IonicModule
 * @param {any} appRoot The root AppComponent for this app.
 * @param {any} config Config Options for the app. Accepts any config property.
 * @param {any} deepLinkConfig Any configuration needed for the Ionic Deeplinker.
 */
 static forRoot(appRoot: any,  
                config: any = null, 
                deepLinkConfig: DeepLinkConfig = null): ModuleWithProviders {

For bootstrapping a single page you could try IonicPageModule.

@NgModule({
   imports: [IonicModule],
   exports: [IonicModule]
})
export class IonicPageModule {

   static forChild(page: any): ModuleWithProviders {

Change your import to :

 imports: [
    IonicPageModule.forChild(Login),
  ]

Update:

Relevant links:IonicPage, IonicPageModule.

According to the google docs shared in discussion here this is introduced in ionic 3 for lazy loading of ionic pages.

like image 150
Suraj Rao Avatar answered Nov 05 '22 20:11

Suraj Rao