tnicola / ngx-joyride

Angular Joyride/Tour library
https://tnicola.github.io/ngx-joyride/
MIT License
245 stars 97 forks source link

Object is possibly 'undefined'. #600

Open sultanmyrza opened 2 years ago

sultanmyrza commented 2 years ago

By following this guide I'm trying to call my function when the user finishes the tutorial but got Object is possibly 'undefined'. error

Screen Shot 2022-05-23 at 3 00 09 PM

Rouvas commented 2 years ago

Got the same error. Angular 12.0.3 Снимок экрана 2022-08-10 172413

Rouvas commented 2 years ago

Solution found by going to tsconfig.json and setting strict: false

image

CarsonHam commented 1 month ago

A better way to solve this would be to subscribe to the event in the component class in the ngAfterViewInit() lifecycle hook:

@ViewChild(JoyrideDirective) joyride: JoyrideDirective;

sub: Subscription;

ngAfterViewInit() {
    this.sub = this.joyride.done!.subscribe(_ => captureWithCustomCamera());
}

ngOnDestroy() {
    this.sub.unsubscribe();
}