Having an issue with the beacon Minor propriety in a new function. The editor keeps saying that the name cannot be found, and I'm not sure how to resolve it.
Function Example:
listenToBeaconEvents() {
this.events.subscribe('didRangeBeaconsInRegion', (data) => {
// update the UI with the beacon list
this.zone.run(() => {
this.beacons = [];
let beaconList = data.beacons;
beaconList.forEach((beacon) => {
let beaconObject = new BeaconModel(beacon);
this.beacons.push(beaconObject);
console.log(beacon.minor);
});
});
});
}
In the above function, console.log(beacon.minor)
displays the expected result within the function. However, trying to access it outside of the function doesn't work as intended.
For example:
isThatBeacon() {
if (beacon.minor == 12345) {
console.log('beacon found');
}
}
Your help is appreciated.
UPDATE
After implementing Nitzan's solution, the editor error is resolved. However, when testing on the device, I encountered the following error:
inline template:22:4 caused by: Cannot read property 'minor' of undefined
The relevant HTML snippet for reference:
<button class="danger" (click)="isThatBeacon()">is working?</button>
Thank you.