我尝试使用ionic/ngx相机制作一个带有ionic-angular的应用程序,但是尽管在module.ts部分添加了相机提供程序,我还是不断收到这个错误。
This is the error
这是我的模块
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);
}
}
1条答案
按热度按时间e4yzc0pl1#
你需要提供相机在模块中使用相机插件,你有它的位置不正确的应用程序。组件,将其移动到使用相机的组件.