I have the following code:
import {Component} from '@angular/core';
import {DocumentScanner, DocumentScannerOptions, DocumentScannerSourceType} from '@ionic-native/document-scanner';
@Component({
selector: 'app-tab2',
templateUrl: 'tab2.page.html',
styleUrls: ['tab2.page.scss']
})
export class Tab2Page {
constructor(private documentScanner: DocumentScanner) {
}
scan() {
const opts: DocumentScannerOptions = {
sourceType: DocumentScannerSourceType.CAMERA,
fileName: 'ticketScan.png',
quality: 100,
returnBase64: true
};
this.documentScanner.scanDoc(opts)
.then((res: string) => console.log(res))
.catch((error: any) => console.error(error));
}
}
When i run this i get the following error:
11:42 'DocumentScanner' refers to a value, but is being used as a type here.
can anyone tell me why this is happening?
You need to import DocumentScanner in your app.module.ts file
import { DocumentScanner } from '@ionic-native/document-scanner/ngx';
and also add it to the provider array
providers: [
.....
DocumentScanner ,
.....
]
Also in your page.ts file, add /ngx/; after the document scanner import path like
import { DocumentScanner } from '@ionic-native/document-scanner/ngx/';
Hope it helps.
As mentioned here , if any file in your project has a missing /ngx
import, it may cause issues even in files where /ngx
is present.
So you should check every file for missing /ngx
imports.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.