Answered

Accessing angular service from within @typeform/embed createWidget onSubmit callback

  • 19 March 2022
  • 2 replies
  • 102 views

I embedded a Typeform in an Angular component using the vanilla sdk: https://www.npmjs.com/package/@typeform/embedapk-standard successfully.

However when I try to access an Angular service from within the onSubmit callback function I get the following error.

ERROR TypeError: Cannot read properties of undefined (reading '_authService')

Here's the code:

export class OnboardComponent implements AfterViewInit {

@ViewChild('formContainer') formContainer:any;

constructor(private _userService:UserService, private _authService: AuthService) {
}

ngAfterViewInit(): void {
createWidget("<<Form ID>>", {
enableSandbox: true,
container: this.formContainer.nativeElement,
onSubmit: this.formFilled,
});
}

formFilled() {
this._authService.currentUser$.subscribe(user => {
this._userService.setUserOnboarded(user);
});
}
}

Any ideas of how to fix this?

icon

Best answer by john.desborough 19 March 2022, 17:00

View original

2 replies

Userlevel 7
Badge +6

@apk127y0 - welcome to the community.. the weekend might be quiet with folks from Typeform who are able to help here in the community. 

to get an added vector of support, suggest you raise a help ticket with Typeform Support at this link 

 

des

Userlevel 7
Badge +5

Hi @apk127y0 Were you able to reach our support team? 😀

Reply