错误:模块'AppModule'

时间:2017-03-24 10:59:09

标签: ionic2 custom-component

我是离线2的新手,按照本教程https://www.joshmorony.com/creating-a-custom-expandable-header-component-for-ionic-2/我想显示Expandable标头组件。在我ionic g component ExpandableHeader中导入自定义组件时,我创建了自定义组件命名app.module.ts

以下是我的app.module.ts代码:

import { ExpandableHeader } from '../components/expandable-
        header/expandable-header';
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

@NgModule({
 declarations: [
 MyApp,
 HomePage,
 ExpandableHeader
],
imports: [
  IonicModule.forRoot(MyApp)
],
 bootstrap: [IonicApp],
entryComponents: [
 MyApp,
 HomePage
],
 providers: [
  StatusBar,
  SplashScreen,
  {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
 })
export class AppModule {}

当我尝试导入时显示错误。如何解决此错误

1 个答案:

答案 0 :(得分:1)

试试这个providers: [StatusBar,SplashScreen,ErrorHandler]

并尝试在页面构造函数中定义provide:useClass