We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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) { }
ngOnInit(): void { this.nfc.doStartTagListener.bind(this) this.nfc.doStartTagListener(this.searchAthlet).then(() => console.log(this)) } ngOnDestroy(): void { this.nfc.doStopTagListener() } searchAthlet(data: NfcTagData) { this.routerExtensions.navigate(['sporttrack', athlet.phone]) }
}
` service
` @Injectable({ providedIn: 'root' }) export class SporttrackNfcService { nfc: Nfc
constructor() { this.nfc = new Nfc() } 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)) fn(data) }).then(() => { console.log('OnTagDiscovered Listener set') }, (err) => { console.log(err) }) } doStopTagListener() { this.nfc.setOnTagDiscoveredListener(null).then(() => { console.log('OnTagDiscovered nulled') }, (err) => { console.log(err) }) }
`
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:
The text was updated successfully, but these errors were encountered:
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) }) }
Sorry, something went wrong.
I resolve this
No branches or pull requests
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:
`
The text was updated successfully, but these errors were encountered: