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

Alternative to typeform for API answers

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

View original

3 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15034 replies
  • February 22, 2022

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


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • 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
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15034 replies
  • March 1, 2022

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


Reply