Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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
Html Can';t列出ionic2中存在的蓝牙设备列表_Html_Angularjs_Bluetooth_Ionic2 - Fatal编程技术网

Html Can';t列出ionic2中存在的蓝牙设备列表

Html Can';t列出ionic2中存在的蓝牙设备列表,html,angularjs,bluetooth,ionic2,Html,Angularjs,Bluetooth,Ionic2,我想显示Ionic2中存在的蓝牙设备列表 我在爱奥尼亚制作了.ts和.html页面 现在我可以使用该应用程序在手机上打开蓝牙,但看不到其他设备 .ts文件: import { Component } from '@angular/core'; import { Platform, AlertController } from 'ionic-angular'; import { BluetoothSerial } from 'ionic-native'; import { NavControlle

我想显示Ionic2中存在的蓝牙设备列表

我在爱奥尼亚制作了.ts和.html页面

现在我可以使用该应用程序在手机上打开蓝牙,但看不到其他设备

.ts文件:

import { Component } from '@angular/core';
import { Platform, AlertController } from 'ionic-angular';
import { BluetoothSerial } from 'ionic-native';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-page1',
  templateUrl: 'page1.html'
})
export class Page1 {
public working:string;
public var2: string ;
public lists = [];

  constructor(private alertCtrl: AlertController, public platform: Platform, public navCtrl: NavController) {
    platform.ready().then(() => {
      BluetoothSerial.isConnected()
      .then(() => {
          console.log('is connected');
      }, (err) => {
          console.log(' not connected')
      })
    });
  }

  enableBluetooth(){
    BluetoothSerial.enable()
  }

  discoverBluetooth(){   
    /*   BluetoothSerial.setDeviceDiscoveredListener(function(device) {
      console.log('Found: '+device.id);
    });*/
  }

  unpairedBluetooth(){
    BluetoothSerial.discoverUnpaired().then(function(devices) {
      devices.forEach(function(device) {
        console.log(device.id)
      });
    })
  }

  listDevices(){
    BluetoothSerial.isEnabled().then((data)=> {
      console.log(data);
      BluetoothSerial.list().then((allDevices) => {
        this.lists = allDevices;
        let result = [];
        for (var out in this.lists) {          
          result.push(out);
        }
      })
    })
  }}
.html文件:

<ion-header>
  <ion-navbar>
    <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>Page One</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>


    <ion-buttons>
<button ion-button (click) = "enableBluetooth()">Turn on bluetooth</button>
</ion-buttons>
 <ion-buttons>
<button ion-button (click) = "listDevices()">List devices</button>
</ion-buttons>

    <ion-list>
        <ion-item *ngFor="let out of lists">{{out}}</ion-item>
    </ion-list>

 <ion-buttons>
<button ion-button (click) = "unpairedBluetooth()">Unpair</button>
</ion-buttons>
</ion-content>

我该怎么读这些呢?

我想在这一行:

 <ion-item *ngFor="let out of lists">{{out}}</ion-item>

我认为在这方面:

 <ion-item *ngFor="let out of lists">{{out}}</ion-item>
[{
"class": 276,
"id": "10:BF:48:CB:00:00",
"address": "10:BF:48:CB:00:00",
"name": "Nexus 7"
}]