Reputation: 11
I am trying to cordova-plugin-document-scanner in my ionic application. but in my device ready function, I cannot access the global scan object. Here is the code
this.platform.ready().then((readySource) => {
console.log('Platform ready from', readySource);
// Platform now ready, execute any required native code
console.log(scan);
});
and here is the exception
Error: Uncaught (in promise): ReferenceError: 'scan' is not defined
ReferenceError: 'scan' is not defined
at Anonymous function (http://localhost:8100/build/main.js:839:13)
at t.prototype.invoke (http://localhost:8100/build/polyfills.js:3:14879)
at onInvoke (http://localhost:8100/build/vendor.js:5134:17)
at t.prototype.invoke (http://localhost:8100/build/polyfills.js:3:14879)
at r.prototype.run (http://localhost:8100/build/polyfills.js:3:10117)
at Anonymous function (http://localhost:8100/build/polyfills.js:3:20233)
at t.prototype.invokeTask
Can anybody help me where I am going wrong?
Upvotes: 1
Views: 1167
Reputation: 106
nice seeing you here :)
Just linking the solved github issue here, for future users.
Here are the steps :-
1) Create blank Ionic Project in terminal
ionic start myproject blank
2) Add plugin to project
ionic cordova plugin add cordova-plugin-document-scanner
3) Now navigate to E:\myproject\src\app\app.component.ts
- add declare var scan;
above @Component({..
- then inside platform.ready().then(() => { }
function add
the following function as shown in readme.
scan.scanDoc(1, onSuccess, onFail);
function onSuccess(imageURI) {
//var image = document.getElementById('myImage');
//image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
4) Then in terminal ionic cordova run android
5) Also don't forget to read the documentation and the other solutions to issues if you run into trouble.
Have a nice day all of you :)
Upvotes: 2