简体   繁体   English

Ionic Angular 中没有 Camera-Injection-Error 的提供者(在 Module.ts 中有提供者)

[英]No provider for Camera-Injection-Error (with provider in Module.ts) in Ionic Angular

im trying to make an app with ionic-angular using ionic/ngx camera, but I keep getting this error in spite of adding the camera provider in the module.ts section.我正在尝试使用 ionic/ngx 相机制作一个带有 ionic-angular 的应用程序,但尽管在 module.ts 部分添加了相机提供程序,但我仍然收到此错误。

This is the error这是错误

And this is my module.ts这是我的 module.ts

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { RouteReuseStrategy } from '@angular/router';


    import { IonicModule, IonicRouteStrategy } from '@ionic/angular';

    import { AppComponent } from './app.component';
    import { AppRoutingModule } from './app-routing.module';

    import { IonicStorageModule } from '@ionic/storage-angular';
    import {AuthGuardService} from './services/auth-guard.service';
    import {AuthenticationService} from './services/authentication.service';
    import {Storage} from '@ionic/Storage';
    import { HttpClientModule } from '@angular/common/http';
    import { QRCodeModule } from 'angularx-qrcode';
    **import { Camera } from '@ionic-native/camera/ngx';**


    @NgModule({
    declarations: [AppComponent],
    imports: [ BrowserModule, IonicModule.forRoot(), AppRoutingModule,IonicStorageModule.forRoot(),                         QRCodeModule],
    providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, **Camera**],
    bootstrap: [AppComponent],
    })
    export class AppModule {}

The method im trying to pull of is this one我尝试使用的方法是这个

 export class PhotoService{
  constructor(private camera: Camera){}




    takePicture(){
      const fotito = Image;
      const options: CameraOptions ={
        quality: 100,
        destinationType: this.camera.DestinationType.DATA_URL,
        encodingType: this.camera.EncodingType.JPEG,
        mediaType: this.camera.MediaType.PICTURE,
      }


    this.camera.getPicture(options).then((imageData) => {imageData= fotito

    },(err) =>{console.log('Problemas de camara' + err);

  })
  return(fotito);
 }
}

You need to provide the Camera in the module that uses the camera plugin, You have it place incorrectly in the app.component, move it to the component that uses the camera.您需要在使用相机插件的模块中提供相机,您将其错误地放置在 app.component 中,将其移动到使用相机的组件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM