core.js:6228错误错误:未捕获(承诺):TypeError:无法读取未定义的属性“ id”

时间:2020-06-14 10:11:45

标签: angular ionic-framework

当我在模块中导入任何内容以通过使用任何服务将其注入控制器中时,总是会遇到此问题

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { HomePage } from './home.page';
// import { PhotoLibrary } from '@ionic-native/photo-library/ngx';
import { AngularFirestore } from '@angular/fire/firestore';


import { HomePageRoutingModule } from './home-routing.module';


@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    HomePageRoutingModule,
    // PhotoLibrary,
    AngularFirestore
  ],
  declarations: [HomePage]
})
export class HomePageModule {}

在此代码段中,无论何时添加PhotoLibrary或AngularFirestore,都会给我错误:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'id' of undefined
TypeError: Cannot read property 'id' of undefined
at registerNgModuleType (vendor.js:68335)
at vendor.js:68353
at Array.forEach (<anonymous>)
at registerNgModuleType (vendor.js:68349)
at new NgModuleFactory$1 (vendor.js:68496)
at Compiler_compileModuleSync__POST_R3__ (vendor.js:72488)
at Compiler_compileModuleAsync__POST_R3__ [as compileModuleAsync] (vendor.js:72501)
at MergeMapSubscriber.project (vendor.js:98784)
at MergeMapSubscriber._tryNext (vendor.js:140384)
at MergeMapSubscriber._next (vendor.js:140374)
at resolvePromise (polyfills.js:3904)
at resolvePromise (polyfills.js:3856)
at polyfills.js:3966
at ZoneDelegate.invokeTask (polyfills.js:3505)
at Object.onInvokeTask (vendor.js:72989)
at ZoneDelegate.invokeTask (polyfills.js:3504)
at Zone.runTask (polyfills.js:3273)
at drainMicroTaskQueue (polyfills.js:3675)

1 个答案:

答案 0 :(得分:0)

对于拥有ng-recaptcha的人来说,issue#177 (comment)的依赖关系必须从 4.2.1 (及更早版本)升级到Angular <兼容> 9/10 ,例如(截至今天) 5.0.0