Open ivanff opened 5 years ago
ngOnInit(): void { this.zone.runOutsideAngular(() => { this.nfc.doStartTagListener(this.searchAthlet.bind(this)) }) }
doStartTagListener(fn: (data: NfcTagData) => any): Promise<any> { return this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => { console.dir(data, this.nfc) console.log('Tag discovered sporttrack scan! ' + JSON.stringify(data)) this.zone.run(() => fn(data)) }).then(() => { console.log('OnTagDiscovered Listener set') }, (err) => { console.log(err) }) }
I resolve this
I can't get routerExtension inside callback when i write service
component:
` @Component({ selector: 'app-sporttrack', templateUrl: './sporttrackSearch.component.html', styleUrls: ['./sporttrack.component.scss'] }) export class SporttrackSearchComponent implements OnInit, OnDestroy { constructor(public routerExtensions: RouterExtensions, private nfc: SporttrackNfcService, public zone: NgZone) { }
}
` service
` @Injectable({ providedIn: 'root' }) export class SporttrackNfcService { nfc: Nfc
}
`
ERROR `
Tag discovered sporttrack scan! {"id":[4,72,-37,26,-32,95,-127],"techList":["android.nfc.tech.NfcA","android.nfc.tech.MifareUltralight","android.nfc.tech.NdefFormatable"]} JS: 123 JS: Unhandled Promise rejection: Cannot read property 'routerExtensions' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot read property 'routerExtensions' of undefined TypeError: Cannot read property 'routerExtensions' of undefined
JS: at file:///src/app/sporttrack/sporttrack.component.ts:243:21
JS: at file:///node_modules/nativescript-plugin-firebase/firebase.js:2348:51
JS: at Array.map ()
JS: at QuerySnapshot.push.../node_modules/nativescript-plugin-firebase/firebase.js.QuerySnapshot.forEach file:///node_modules/nativescript-plugin-firebase/firebase.js:2348:0
JS: at file:///src/app/sporttrack/sporttrack.component.ts:241:21
JS:
`