Error when importing Ionic page

0

The page that I want to import works very well in a page that calls it in a previous event (Login) but now I can not import any, it is as if it were truncated in project

When I want to import a page into another predefined page in app.module I get the following error

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[MainPage -> PersonaEventoPage]: 
  StaticInjectorError(Platform: core)[MainPage -> PersonaEventoPage]: 
    NullInjectorError: No provider for PersonaEventoPage!


Error: StaticInjectorError(AppModule)[MainPage -> PersonaEventoPage]: 
  StaticInjectorError(Platform: core)[MainPage -> PersonaEventoPage]: 
    NullInjectorError: No provider for PersonaEventoPage!
    at _NullInjector.get (vendor.js:1376)
    at resolveToken (vendor.js:1674)
    at tryResolveToken (vendor.js:1616)
    at StaticInjector.get (vendor.js:1484)
    at resolveToken (vendor.js:1674)
    at tryResolveToken (vendor.js:1616)
    at StaticInjector.get (vendor.js:1484)
    at resolveNgModuleDep (vendor.js:11228)
    at NgModuleRef_.get (vendor.js:12461)
    at resolveDep (vendor.js:12951)
    at _NullInjector.get (vendor.js:1376)
    at resolveToken (vendor.js:1674)
    at tryResolveToken (vendor.js:1616)
    at StaticInjector.get (vendor.js:1484)
    at resolveToken (vendor.js:1674)
    at tryResolveToken (vendor.js:1616)
    at StaticInjector.get (vendor.js:1484)
    at resolveNgModuleDep (vendor.js:11228)
    at NgModuleRef_.get (vendor.js:12461)
    at resolveDep (vendor.js:12951)
    at c (polyfills.js:3)
    at Object.reject (polyfills.js:3)
    at NavControllerBase._fireError (vendor.js:51758)
    at NavControllerBase._failed (vendor.js:51751)
    at vendor.js:51798
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (vendor.js:5123)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3

My app module

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { ScreenSplashPage } from '../pages/screen-splash/screen-splash';
import { ActividadLoginPage } from '../pages/actividad-login/actividad-login';
import { DatabaseProvider } from '../providers/database/database';
import { DeseosPersonaPage } from '../pages/deseos-persona/deseos-persona';
import { SQLite } from '@ionic-native/sqlite';
import { WsProvider } from '../providers/ws/ws';
import { HttpModule } from '@angular/http';
import { MainPage } from '../pages/main/main';
import { Network } from '@ionic-native/network';
import { InternetListenerProvider } from '../providers/internet-listener/internet-listener';
import { MapaDireccionPage } from './../pages/mapa-direccion/mapa-direccion';
import { PersonaEventoPage } from '../pages/persona-evento/persona-evento';
import { InvitacionesPage } from '../pages/invitaciones/invitaciones';

@NgModule({
    declarations: [
        MyApp,
        ScreenSplashPage,
        ActividadLoginPage,
        DeseosPersonaPage,
        MainPage,
        MapaDireccionPage,
        PersonaEventoPage,
        InvitacionesPage
    ],
    imports: [
        BrowserModule,
        HttpModule,
        IonicModule.forRoot(MyApp)
    ],
    bootstrap: [IonicApp],
    entryComponents: [
        MyApp,
        ScreenSplashPage,
        ActividadLoginPage,
        DeseosPersonaPage,
        MainPage,
        MapaDireccionPage,
        PersonaEventoPage,
        InvitacionesPage
    ],
    providers: [
        StatusBar,
        SplashScreen,
        SQLite,
        {provide: ErrorHandler, useClass: IonicErrorHandler},
        DatabaseProvider,
        WsProvider,
        Network,
        InternetListenerProvider
    ]
})
export class AppModule {}
    
asked by Jesus David Cleves Martinez 17.04.2018 в 14:45
source

1 answer

0

I solved it by adding an array to the providers object in the page where I needed to import with the import variables of the page

    @Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers: [SiguientePaginaPage]
})

The complete TypeScript would remain this way

    import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { SiguientePaginaPage } from '../siguiente-pagina/siguiente-pagina';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers: [SiguientePaginaPage]
})
export class HomePage {

  constructor(public navCtrl: NavController, public siguientePaginaPage:SiguientePaginaPage) {
    console.log(siguientePaginaPage.variable);
  }

}
    
answered by 24.04.2018 / 15:13
source