1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Adding feedback page to scanning function in Ionic 2 app

Discussão em 'Angular' iniciado por cantona_7, Agosto 9, 2025.

  1. cantona_7

    cantona_7 Guest

    I have developed an app to launch a url and added the scan function to it. I would like to add a feedback page (I mean, once I scan the QR code, I would like to see the result in next page). The scan function works fine and I have generated a page as well but once I add this the whole function doesn't work.

    Home.ts

    import {Component} from '@angular/core';
    import {NavController} from 'ionic-angular';
    import {Platform} from 'ionic-angular';
    import {BarcodeScanner} from 'ionic-native';
    import {ScannedPage} from '../scanned-page/scanned-page';
    @Component({
    templateUrl: 'home.html'
    })
    export class HomePage {
    private barcodeText: String;
    private barcodeFormat: String;
    private platform: Platform;
    private navController: NavController;

    constructor(public navCtrl: NavController, platform: Platform) {
    this.platform = platform;
    this.navController = navCtrl;
    }
    scanningDone(data) {
    this.navController.push(ScannedPage, {
    data: data
    });
    }

    doScan() {
    console.log('scannig product barcode');
    this.platform.ready().then(() => {
    BarcodeScanner.scan().then((result) => {
    if (!result.cancelled) {
    this.barcodeText = result.text;
    this.barcodeFormat = result.format;
    this.scanningDone({
    'text': result.text,
    'format': result.format
    });
    }
    },
    (error) => {
    console.log('error when scanning product barcode');
    });
    });
    }
    }


    Scanned-page.ts

    import { Component } from '@angular/core';
    import { NavController,NavParams } from 'ionic-angular';
    import { HomePage } from '../pages/home/home'
    @Component({
    templateUrl: 'scanned-page.html',
    })
    export class ScannedPage {
    rootPage = HomePage;
    private bcData;
    constructor(private navCtrl: NavController,navParams: NavParams) {
    this.bcData = navParams.get('data');
    }
    }


    app.module.ts

    import { NgModule, ErrorHandler } from '@angular/core';
    import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
    import { HomePage } from '../pages/home/home';
    import { ScannedPage } from '../pages/scanned-page/scanned-page';
    import { MyApp } from './app.component';

    @NgModule({
    declarations: [
    MyApp,
    HomePage,
    ScannedPage
    ],
    imports: [
    IonicModule.forRoot(MyApp)
    ],
    bootstrap: [IonicApp],
    entryComponents: [
    MyApp,
    HomePage,
    ScannedPage
    ],
    providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
    })
    export class AppModule {}


    [​IMG]

    Continue reading...

Compartilhe esta Página