Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Ionic 2 and Barcode plugin

$
0
0

Try this:

    if (cordova.plugins.barcodeScanner) {
        cordova.plugins.barcodeScanner.scan((imageData) => {
			this.nav.push(ItemDetailsPage, {
					itemid: imageData.text
				}
			)
        }, (error) => {
			alert("An error happened -> " + error);
        });
    }

I've added some braces around your fat arrow function, and also changed the if condition since it would make more sense to check for the existence of the barcode scanner object. Also, since you are using fat arrow functions, there is no need to create a reference to 'this' because it will use the parents scope anyway.


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>