Skip to main content
Answer

Alternative to typeform for API answers

  • February 22, 2022
  • 3 replies
  • 78 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

 

Best answer by mathio-tf

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

3 replies

Liz
Ex–Typefomer
Forum|alt.badge.img+5
  • Tech Community Advocate
  • February 22, 2022

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


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • Answer
  • February 22, 2022

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


Liz
Ex–Typefomer
Forum|alt.badge.img+5
  • Tech Community Advocate
  • March 1, 2022

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