错误:未捕获(承诺)-角度错误-NullInjectorError:

时间:2020-08-04 14:25:12

标签: angular error-handling module

仅在我拥有的组件的构造函数中放置“ private homePage:HomePage”,就出现了此错误。

Idk为什么会发生这种情况

错误:

Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[PaymentMethodComponent -> HomePage]: 
  StaticInjectorError(Platform: core)[PaymentMethodComponent -> HomePage]: 
    NullInjectorError: No provider for HomePage!
NullInjectorError: StaticInjectorError(AppModule)[PaymentMethodComponent -> HomePage]: 
  StaticInjectorError(Platform: core)[PaymentMethodComponent -> HomePage]: 
    NullInjectorError: No provider for HomePage!
    at NullInjector.get (core.js:855)
    at resolveToken (core.js:17514)
    at tryResolveToken (core.js:17440)
    at StaticInjector.get (core.js:17266)
    at resolveToken (core.js:17514)
    at tryResolveToken (core.js:17440)
    at StaticInjector.get (core.js:17266)
    at resolveNgModuleDep (core.js:30393)
    at NgModuleRef_.get (core.js:31578)
    at resolveDep (core.js:32143)
    at resolvePromise (zone-evergreen.js:797)
    at new ZoneAwarePromise (zone-evergreen.js:879)
    at fesm5.js:3145
    at ZoneDelegate.invoke (zone-evergreen.js:359)
    at Object.onInvoke (core.js:39699)
    at ZoneDelegate.invoke (zone-evergreen.js:358)
    at Zone.run (zone-evergreen.js:124)
    at NgZone.run (core.js:39511)
    at AngularFrameworkDelegate.push../node_modules/@ionic/angular/dist/fesm5.js.AngularFrameworkDelegate.attachViewToDom (fesm5.js:3141)
    at attachComponent (framework-delegate-c2e2e1f4.js:3)

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

您是否尝试在component.ts中添加提供程序?

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ],
  providers: [HomePage]
 })
相关问题