IONIC 3:"错误:找不到组件工厂.... entryComponents?"

时间:2017-12-09 15:01:27

标签: ionic-framework storage provider

为什么我会收到此错误?

  

错误:找不到DatabaseProvider的组件工厂。你添加了它吗?   到@ NgModule.entryComponents?

我尝试将我的提供程序添加到entryComponents中,但仍无效。

database.ts

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

import { Storage } from '@ionic/storage';

@Injectable()
export class DatabaseProvider {
  localData: any;
  constructor() {
    console.log('Database provider iniciado ..'); 
  }
}

我的设置 ,使用此提供商,我尝试制作本地存储空间,但我无法使用此提供商。

app.module.ts

import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { DatabaseProvider } from '../providers/database/database';
import { IonicStorageModule } from '@ionic/storage';

@NgModule({
  declarations: [
    MyApp,
    InicioPage,
    SimuladorPage,
    NosotrosPage,
    CuestionarioPage,
    CuestinarioPorCompetenciaPage,
    PersonalizadoPage,
    CRUDPage,
    NormasPage,
    CategoriasPage,
    VerCategoriasPage,
    PreguntasPage,
    AlternativasPage,
    FeedbackPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(DatabaseProvider),
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    InicioPage,
    SimuladorPage,
    NosotrosPage,
    CuestionarioPage,
    CuestinarioPorCompetenciaPage,
    PersonalizadoPage,
    CRUDPage,
    NormasPage,
    CategoriasPage,
    VerCategoriasPage,
    PreguntasPage,
    AlternativasPage,
    FeedbackPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    DatabaseProvider
  ]
})
export class AppModule {}

1 个答案:

答案 0 :(得分:0)

我只需要制作一个新项目......