Answered

Alternative to typeform for API answers

  • 22 February 2022
  • 3 replies
  • 57 views

 

I'm embedding a Typeform in Angular component according to SDK.

Component template has div:

<div
#embedTypeform
style="width: 100%; height: 500px;"
></div>

And I'm using SDK in AfterViewInit:

import { Component, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import * as typeformEmbed from '@typeform/embed';

@Component({
selector: 'app-answer-form',
templateUrl: './answer-form.component.html',
styleUrls: ['./answer-form.component.css']
})
export class AnswerFormComponent implements AfterViewInit {
@ViewChild('embedTypeform', { static: false }) embedElement: ElementRef;

ngAfterViewInit() {
if (this.embedElement) {
console.log(this.embedElement);
typeformEmbed.makeWidget(
this.embedElement,
'https://xxx.typeform.com/to/xxx',
{
hideHeaders: true,
hideFooter: true,
opacity: 75,
buttonText: 'Take the survey!',
onSubmit: () => {
console.log('Typeform successfully submitted');
}
}
);
}
}

}

And in effect I get

TypeError: Cannot read property 'length' of undefined

Any ideas? appliances

 

icon

Best answer by mathio 22 February 2022, 16:57

View original

3 replies

Userlevel 7
Badge +5

@mathio do you happen to know why this error is showing? :grinning:

Userlevel 7
Badge +5

Hello @jackkle234 

you are using old version of the embed lib. Where did you find the documentation for that please? We are trying to update all our docs to use latest embed SDK.

Please use latest embed SDK - you can upgrade via yarn add @typeform/embed or npm install --save @typeform/embed

Userlevel 7
Badge +5

Hi @jackkle234 were you able to update to the new Embed SDK? 

Reply