Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

Ionic 2 and Barcode plugin

$
0
0

@lonangel wrote:

Hi,
I'm trying to get the phonegap-plugin-barcodescanner to work with ionic 2.
This is the code I'm trying to use.

import {Page, NavController} from 'ionic-framework/ionic';
import {ItemDetailsPage} from '../item-details/item-details';

@Page({
templateUrl: 'build/pages/getting-started/getting-started.html'
})

export class GettingStartedPage {
nav:NavController;

constructor(nav:NavController) {
    this.nav = nav;
}

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

}

}

The Idea was to read the barcode and send the value to another page to show some details about the item.
Trying it on my Nexus 5 I don't see any errors on the adb.

Best Regards,
Duarte

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles



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