类型“AppVersionOriginal”是不能分配给输入“供应商”。类型“AppVersionOriginal”缺少下列properti

问题描述 投票:2回答:1

我已创建使用通过以下离子CLI v4.9.0最新版的新型离子3应用

$ ionic start Ionic3Project blank --type ionic-angular

其默认创建V4离子项目。

然后,我遵循的原生应用程序版本插件here步骤

在app.module.ts文件导入当遇到以下控制台错误

Uncaught Error: Invalid provider for the NgModule 'AppModule' - only instances of Provider and Type are allowed, got: [StatusBar, ?[object Object]?, ...]
at syntaxError (compiler.js:486)
at compiler.js:15784
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (compiler.js:15752)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:15320)
at JitCompiler._loadModules (compiler.js:34413)
at JitCompiler._compileModuleAndComponents (compiler.js:34374)
at JitCompiler.compileModuleAsync (compiler.js:34268)
at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:239)
at PlatformRef.bootstrapModule (core.js:5578)

app.module.ts文件

    import { BrowserModule } from '@angular/platform-browser';
    import { ErrorHandler, NgModule } from '@angular/core';
    import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
    import { SplashScreen } from '@ionic-native/splash-screen';
    import { StatusBar } from '@ionic-native/status-bar';
    import { AppVersion } from '@ionic-native/app-version';

    import { MyApp } from './app.component';
    import { HomePage } from '../pages/home/home';

    @NgModule({
      declarations: [
        MyApp,
        HomePage
      ],
      imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp)
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        HomePage
      ],
      providers: [
        StatusBar,
        AppVersion, <-- Error [[ts]
                                Type 'AppVersionOriginal' is not assignable to type 'Provider'.
                                Type 'AppVersionOriginal' is missing the following properties from type 'FactoryProvider': provide, useFactory [2322]]
        SplashScreen,
        {provide: ErrorHandler, useClass: IonicErrorHandler}
      ]
    })
    export class AppModule {}

更新:最后,我发现这个问题here的答案和解释:P

ionic-framework ionic-native ionic4
1个回答
5
投票

这个问题是因为离子新的更新(释放离子4)你必须导入插件离子3所示:

import { PluginName} from '@ionic-native/pluginName/ngx';

More info here

© www.soinside.com 2019 - 2024. All rights reserved.