Ionic framework 使用CallNumber获取无效的提供程序错误

Ionic framework 使用CallNumber获取无效的提供程序错误,ionic-framework,phone-call,Ionic Framework,Phone Call,我是电话号码。 如果我遵循,则未提及在提供程序中包含CallNumber,因此引发错误: 错误:未捕获(承诺中):NullInjector错误: R3InjectorError(HomePageModule)[呼叫号码->呼叫号码->呼叫号码 ->CallNumber]:NullInjectorError:没有CallNumber的提供程序 因此,我在app.module.ts中将CallNumber添加为提供商 import { CallNumber } from '@ionic-native

我是电话号码。 如果我遵循,则未提及在提供程序中包含CallNumber,因此引发错误:

错误:未捕获(承诺中):NullInjector错误: R3InjectorError(HomePageModule)[呼叫号码->呼叫号码->呼叫号码 ->CallNumber]:NullInjectorError:没有CallNumber的提供程序

因此,我在app.module.ts中将CallNumber添加为提供商

import { CallNumber } from '@ionic-native/call-number';


@NgModule({
  declarations: [AppComponent, StudentModalPage],
  imports: [
    BrowserModule.withServerTransition({ appId: 'serverApp' }),
    BrowserTransferStateModule,
    IonicStorageModule.forRoot(),
    IonicModule.forRoot(),
    FormsModule,
    AppRoutingModule,
    HttpClientModule,
    ComponentsModule,
    ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
  ],
  providers: [
   CallNumber,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
   
    {
      provide: APP_INITIALIZER,
      useFactory: (platformId: object, response: any) => {
        return () => {
          // In the server.ts we added a custom response header with information about the device requesting the app
          if (isPlatformServer(platformId)) {
            if (response && response !== null) {
              // Get custom header from the response sent from the server.ts
              const mobileDeviceHeader = response.get('mobile-device');

              // Set Ionic config mode?
            }
          }
        };
      },
      deps: [PLATFORM_ID, [new Optional(), RESPONSE]],
      multi: true
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
但现在我得到了这个错误:

错误:NgModule“AppModule”的提供程序无效-仅限实例 允许提供程序和类型的,获取:[?[object]?,…,…]

我搜索了allot,找不到解决方案,也没有隐藏错误,任何输入都值得赞赏。

我遇到了一个类似问题的解决方案,并从添加提供商后创建的自动导入更改了导入:

 { CallNumber } from '@ionic-native/call-number';
致:


很高兴听到你找到了修理它的方法。为了添加更多的上下文,您使用的导入是针对Ionic 2/3的(在OP中提到的文档中,导入是
@Ionic native/call number/ngx
,这是正确的导入)。因此,是的,这是一个非常常见的问题,特别是在将Ionic 3应用程序迁移到Ionic 4/5时:)谢谢-让我头疼的是,当我添加提供商时,导入被自动添加,但添加了不正确的导入,为什么会这样?
{ CallNumber } from '@ionic-native/call-number/ngx';