【发布时间】:2021-03-13 07:33:32
【问题描述】:
下面是我的返回布尔承诺的代码
BluetoothEnabled():any {
this.print.isBluetoothPrinterEnabled().then(
() => { return true},
() => { return false}
)
}
这是我的带有 ngif 的离子按钮,它不起作用
<ion-button expand="block"
(click)="startScanning()" *ngIf= 'BluetoothEnabled()'>scan</ion-button>
它进入无限循环..需要改变什么
编辑:
编辑:
startScanning() {
this.pairedDevices = null;
this.unpairedDevices = null;
this.gettingDevices = true;
const unPair = [];
this.print.dicoverBluetoothUnPairedPrinter().then((success) => {
success.forEach((value, key) => {
var exists = false;
....
});
this.unpairedDevices = unPair;
this.gettingDevices = false;
},
(err) => {
console.log(err);
});
this.print.searchBluetoothPrinter().then((success) => {
this.pairedDevices = success;
},
(err) => {
console.log(err);
});
}
这是扫描设备的扫描功能。它将扫描已配对和未配对的设备>>>
【问题讨论】:
-
“不工作”不是问题描述。发生什么了?为什么这是错的?完整引用任何错误。
标签: angular ionic-framework promise