I am very new in ionic.I am making qr code generator and bar code scanner app.I already made that and display that scanned data but I want display that data for some second and on scanner automatically.Code below.
qr.html
<button ion-button full icon-left (click)="createCode()"><ion-icon name="barcode"></ion-icon>Code Generator</button>
<button ion-button full icon-left (click)="scanCode()"><ion-icon name="qr-scanner"></ion-icon>Scanner</button>
<ion-card *ngIf="createdCode">
<ngx-qrcode [qrc-value]="createdCode"></ngx-qrcode>
<ion-card-content>
<p>Value: {{ createdCode }}</p>
</ion-card-content>
</ion-card>
<ion-card *ngIf="scannedCode">
<ion-card-content>
<p>Value : {{ scannedCode }}</p>
</ion-card-content>
</ion-card>
qr.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { BarcodeScanner } from '@ionic-native/barcode-scanner';
@IonicPage()
@Component({
selector: 'page-qr',
templateUrl: 'qr.html',
})
export class QrPage {
qrData=JSON.parse(localStorage.getItem('response'));
createdCode=null;
scannedCode=null;
constructor(public navCtrl: NavController, public navParams: NavParams, private barcodeScanner: BarcodeScanner) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad QrPage');
}
createCode() {
this.createdCode=this.qrData;
}
scanCode() {
this.barcodeScanner.scan().then(barcodeData=>{
this.scannedCode=barcodeData.text; //save scanned code
})
}
}
after click scan button one time. After scan code display it for some second and automatically open scanner.this process continue till I click back button of my device.How I do that? Please help me. Thanks.