0

I have made a QR scanner app using Ionic-Angular. I can read the Vcard but not extract and save the details. please help me out. Provided below are the home.page.html & home.page.ts files Code for the home.page.html file :

<ion-header>
  <ion-toolbar color="primary" >
    <ion-title>
      Kveso QR Scanner
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
      <ion-card>
        <ion-card-header>Result :</ion-card-header>
        <ion-card-content>
          <ion-item *ngIf="scannedCode">
              {{ scannedCode }} 
          </ion-item>
          <ion-button (click)="scanCode()" fill="outline" id="btn-enter" size="default" ><ion-icon name="qr-code-outline" slot="start"></ion-icon>
              Scan Again</ion-button>
        </ion-card-content>
      </ion-card>
</ion-content>

here is the home.page.ts file :

import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'
import { NavController } from '@ionic/angular';
import { NullVisitor } from '@angular/compiler/src/render3/r3_ast';
@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {
  scannedCode: string="";


  constructor(private barcodeScanner : BarcodeScanner,
    private navCtrl : NavController) {}

  scanCode(){
    this.barcodeScanner.scan().then(
      barcodeData => {
        this.scannedCode = barcodeData.text;
      }
    )
  }
  ngAfterViewInit(){
    this.scanCode();
  } 
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.