RaulGM
RaulGM

Reputation: 332

How to display a QR code in phonegap

I'm trying to display a QR_CODE. I get an alert that I have an object, but I can't find the function or property that displays the actual QR_CODE.

My code goes this way:

BarcodeScanner.encode (BarcodeScanner.Encode.TEXT_TYPE, 'Hello World')
  .then ((success) => {
    alert (success);
  }), (error) => {
    alert (error);
  }

I get this alert:

enter image description here

Any ideas? My guess was to alert (success.QR_CODE), but y get a message of undefined.

Upvotes: 0

Views: 39

Answers (1)

RaulGM
RaulGM

Reputation: 332

I figured the answer.

What I had to do is to declare a property inside my class. For me it's called urlImage. Then, inside the encode function:

BarcodeScanner.encode (BarcodeScanner.Encode.TEXT_TYPE, 'Hello World')
  .then ((success) => {
    this.urlImage = success.file;
  }), (error) => {
    alert (error);
  }

Then, in my html code:

<img src="{{imageUrl}}"/>

And that's it.

Upvotes: 1

Related Questions