Я встраиваю Typeform в Angular компонент согласно SDK .
Шаблон компонента имеет div:
<div
#embedTypeform
style="width: 100%; height: 500px;"
></div>
И я использую SDK в 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');
}
}
);
}
}
}
И в результате я получаю
TypeError: Cannot read property 'length' of undefined
Есть идеи?