Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 管理退货';Bluethoth2的承诺_Angular_Cordova_Typescript_Ionic2_Ionic3 - Fatal编程技术网

Angular 管理退货';Bluethoth2的承诺

Angular 管理退货';Bluethoth2的承诺,angular,cordova,typescript,ionic2,ionic3,Angular,Cordova,Typescript,Ionic2,Ionic3,我正在编写一个代码来检查Bluethooth连接是否启用。所以我这样做了: $ ionic plugin add cordova-plugin-bluetooth-serial $ npm install --save @ionic-native/bluetooth-serial 在我的构想中,我有以下几点: construnct(.... private bluetoothSerial: BluetoothSerial, .....){.. 现在在这里 construnct(...

我正在编写一个代码来检查Bluethooth连接是否启用。所以我这样做了:

$ ionic plugin add cordova-plugin-bluetooth-serial
$ npm install --save @ionic-native/bluetooth-serial
在我的构想中,我有以下几点:

construnct(....
  private bluetoothSerial: BluetoothSerial,
  .....){..
现在在这里

construnct(....
  private bluetoothSerial: BluetoothSerial,
  .....){..
this.bluetoothSerial.isEnabled(/*here*/);
 ...}
我需要知道bluethooth是启用还是否

我创建了一个布尔变量,我想把它赋值为真或假,这取决于它是否启用。但是怎么做呢

参考号:

bluetoothSerial.isEnabled(
    function() {
        console.log("Bluetooth is enabled");
        //myboolflag=true; dosen't work!!!
    },
    function() {
        console.log("Bluetooth is *not* enabled");
    }
);

您应该使用如下箭头功能:

bluetoothSerial.isEnabled(
    () => {
        console.log("Bluetooth is enabled");
        this.myboolflag = true; // Should work now!!!
    },
    () => {
        console.log("Bluetooth is *not* enabled");
    }
);

通过使用箭头函数,
属性不会被覆盖,并且仍然引用组件实例。

它给出了此错误。提供的参数与调用目标的任何签名不匹配。它是否提供了更多详细信息?或者应该如何调用
isEnabled
方法?我有一个错误:-内联模板:0:43原因:BluetoothSerial没有提供程序!请尝试将BluetoothSerial包含在NgModule的提供者数组中。我做到了:提供者:[……,BluetoothSerial,…],在appModule.ts中