我是 ionic 2 的新手,按照本教程进行操作 https://www.joshmorony.com/creating-a-custom-expandable-header-component-for-ionic-2/我想显示可扩展标头组件。在这里,我在app.module.ts
中导入自定义组件命名ionic g component ExpandableHeader
。
以下是我的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 {}
当我尝试导入时,它会显示错误。如何解决此错误
试试这个providers: [StatusBar,SplashScreen,ErrorHandler]
并尝试在页面构造函数中定义provide:
和useClass
。