我已成功实施自定义qrcode扫描程序,并按以下方式接收扫描详细信息。
declare var window: any;
@Component({
selector: 'dashboard',
templateUrl: 'dashboard.html'
})
export class DashboardPage {
constructor(public navCtrl: NavController) {
}
public scanAndPayMode(){
if (window.npciLib){
window.npciLib.qrcodereader('', (data:any) => {
this.getAllVPAList(data);
}, function (error:any) {
});
}
}
public getAllVPAList(scanurl: any){
this.commonServices.getAllVirtualList('A').then((result:any)=>{
this.navCtrl.push(IntentPage, {"value": scanurl, "payerObj": result.content});
}).catch((err: any)=>{
})
}
}
扫描完成后,我想转到下一页,其中包含包含预先填充的帐号的付款表单。
<ion-item>
<ion-label stacked>Select Virtual Address</ion-label>
<ion-select [formControl]="vaddr" (ionChange)="fetchName($event)">
<ion-option *ngFor="let vaddrlist of virtualAddrObj" [value]="vaddrlist.accno+'-'+vaddrlist.accname">{{vaddrlist.accno}}</ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="showdebitacc" class="disable-ion-item">
<ion-label stacked>Debit account number</ion-label>
<ion-input [formControl]="dbacct" type="text"></ion-input>
</ion-item>
选择特定帐户后,需要花费时间(近30秒)才能呈现帐户名称(即使在2秒内从API获取数据) 假设我再次点击选择框(第二次),则显示数据。
public fetchName(vpa: any){
this.showdebitacc = true;
this.sendMoneyForm.patchValue({dbacct: vpa.split('-')[1]});
}
这个问题可以帮助任何人吗?
答案 0 :(得分:0)
我已经使用角度NgZone解决了这个问题。
public scanAndPayMode(){
this.ngzone.runOutsideAngular(() => {
if (window.npciLib){
window.npciLib.qrcodereader('', (data:any) => {
this.ngzone.run(() =>{
this.getAllVPAList(data);
});
}, function (error:any) {
});
}
});
}