如何在 Ionic 2 中使用 Barcode-Scanner 重定向到其他视图
How redirect to other view using Barcode-Scanner in Ionic 2
扫描条形码时我需要重定向到另一个视图,我在ionic 2中使用条形码扫描仪。我尝试了推送方法但它不起作用无法加载其他页面,我也尝试通过其他视图的参数。我做错了什么?
第一视图的方法:
async scanBarcode(){
this.options = {
prompt : 'Escanea un codigo de barra...'
}
this.results = await this.barcode.scan(this.options);
this.navCtrl.push(Infoproducto,{ //this not working
resultados: this.results
});
//console.log(this.results);
}
这是我要重定向到的另一个视图:
<div *ngIf="resultados">
<p>{{results.text}}</p>
<p>{{results.format}}</p>
<p>{{results.cancelled}}</p>
</div>
它应该像这样工作:
this.barcodeScanner.scan().then((barcodeData) => {
this.navCtrl.push(SomePage, {data: barcodeDate});
}, (error) => {
// handle error
});
我过去曾成功地使用过类似的东西。
扫描条形码时我需要重定向到另一个视图,我在ionic 2中使用条形码扫描仪。我尝试了推送方法但它不起作用无法加载其他页面,我也尝试通过其他视图的参数。我做错了什么?
第一视图的方法:
async scanBarcode(){
this.options = {
prompt : 'Escanea un codigo de barra...'
}
this.results = await this.barcode.scan(this.options);
this.navCtrl.push(Infoproducto,{ //this not working
resultados: this.results
});
//console.log(this.results);
}
这是我要重定向到的另一个视图:
<div *ngIf="resultados">
<p>{{results.text}}</p>
<p>{{results.format}}</p>
<p>{{results.cancelled}}</p>
</div>
它应该像这样工作:
this.barcodeScanner.scan().then((barcodeData) => {
this.navCtrl.push(SomePage, {data: barcodeDate});
}, (error) => {
// handle error
});
我过去曾成功地使用过类似的东西。