Simple question on routing, I am unable to find a component in app.component.ts which is from another module.
I am using feature module as ‘register-user’, which is as follows:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { LoginComponent } from './login/login.component';
@NgModule( {
imports: [CommonModule,
FormsModule
],
declarations: [
LoginComponent
],
providers: [],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
exports: [
LoginComponent
]
})
export class RegisterUserModule { }
My app.module.ts is as follows:
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { myApp } from './app.component';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { RegisterUserModule } from '../pages/register-user/register-user.module';
@NgModule( {
declarations: [
myApp
],
imports: [
BrowserModule,
RegisterUserModule,
IonicModule.forRoot( myApp )
],
bootstrap: [IonicApp],
entryComponents: [
myApp
],
providers: [
StatusBar,
SplashScreen,
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
})
export class AppModule { }
My app.component.ts is as follows:
import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { RegisterUserModule } from '../pages/register-user/register-user.module';
@Component( {
templateUrl: 'app.html'
})
export class myApp {
@ViewChild( Nav ) nav: Nav;
rootPage: any;
pages: Array<{ title: string, component: any }>;
constructor( public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen ) {
this.initializeApp();
this.rootPage = LoginComponent;
}
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
I get an error as:
**Cannot find name 'LoginComponent'.** and gives error in app.component.ts
Please suggest a solution.