我试图使用ionic/ngx相机制作一个离子角应用程序,但我一直得到这个错误,尽管在模块中添加了相机提供程序。ts部分。
错误
这是我的模块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 {}
我想采用的方法是这个
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);
}
}
你需要在使用Camera插件的模块中提供Camera,如果它在app.component中放置不正确,请将其移动到使用Camera的组件中。