gpt4 book ai didi

angular - NgModule 的提供程序无效 'AppModule'

转载 作者:行者123 更新时间:2023-12-02 21:09:21 28 4
gpt4 key购买 nike

我不明白为什么当我有了新的提供商时,我一次又一次地遇到这个错误。当我有任何其他提供商(如地理定位等)时,我遇到此错误:

Error: Uncaught Error: Invalid provider for the NgModule 'AppModule' - only instances of Provider and Type are allowed, got: [StatusBar, SplashScreen,?[object Object]?, ...]

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 { ImagePicker } from '@ionic-native/image-picker';
import { Crop } from '@ionic-native/crop';
import { AuthService } from '../pages/core/auth.service';
import { UserService } from '../pages/core/user.service';
import { FollowService } from "../pages/core/follow.service";
import { AngularFireModule } from 'angularfire2';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { environment } from '../environment/environment';
import { MyApp } from './app.component';
import { LoginPage } from '../pages/login/login';
import { RegisterPage } from '../pages/register/register';
import { WelcomePage } from '../pages/welcome/welcome';
import { HomePage } from '../pages/home/home';

@NgModule({
declarations: [
MyApp,
LoginPage,
RegisterPage,
WelcomePage,
HomePage,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule,
AngularFireDatabaseModule,
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
LoginPage,
RegisterPage,
WelcomePage,
HomePage,
],
providers: [
StatusBar,
SplashScreen,
ImagePicker,
Crop,
AuthService,
UserService,
FollowService,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}

最佳答案

尝试将 /ngx 添加到路径中,如下所示,在 Ionic 4 中:

import { File } from '@ionic-native/file/ngx';

关于angular - NgModule 的提供程序无效 'AppModule',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54750331/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com