Problem to display new devices using BLE.scan().subscribe()


#1

Hello,

I’m actually using the BLE for a project.
I’m having a problem when I use the scan function.
Here is how I use it:

  BLE.scan([],20).subscribe((device) =>{     
     this.devices.push(device);
      console.log("devices:");
      console.log(this.devices);
});

When I call this function I see in my console the devices, but they are not displaying in my view.
Here is how I try to display the devices, I call the scan function when I click on the button.

<ion-content padding>
 <button ion-button (click)="enableBLE()" > Scan for BLE devices </button>
 <ion-list>
    <ion-item *ngFor="let device of devices">
      <h1>{{device.id}}</h1>
    </ion-item>
 </ion-list>
<ion-content>

I tried using the ChangeDetectorRef with the markForCheck() function to notice angular that the value changed, but it only changed when I pressed a second time my button.
I want to display it without having to press the button a second time.

Do you know what I can do to display the devices I have or where is my problem?
Thanks !


#2

This happens to me,did you get any solution?


#3

public items = new Array();

this.ble.scan([], 60000).subscribe(
data =>{
this.items.push(data);
},
error =>{
}
);