Html Can';t列出ionic2中存在的蓝牙设备列表
我想显示Ionic2中存在的蓝牙设备列表 我在爱奥尼亚制作了.ts和.html页面 现在我可以使用该应用程序在手机上打开蓝牙,但看不到其他设备 .ts文件: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
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"
}]