Alternative to typeform for API answers | Community
Skip to main content

 

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

 

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


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


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


Reply