I really an imported 3rd party script to trigger a function like show_end_screen (below)
my component
import { Router } from '@angular/router';
import { init_game, start_game, stop_game } from '../../assets/js/game';
@Component({})
export class PlayComponent implements OnInit {
constructor(public router:Router) {}
ngOnInit() {
init_game(this.show_end_screen) // load ready
}
show_end_screen(data){
console.log(data) //this works
this.router.navigate(['play']); //"this" is undefined
}
}
init_game(this.show_end_screen) <== Here I am passing show_end_screen to the imported script. when the 3rd party script runs show_end_screen(data) I successfully log data to the console. But i dont have access to this or any other reference to angular
this.router.navigate(['play']); <== here i get a console error
ERROR TypeError: Cannot read property 'nav' of undefined
routerin your component?