I'm trying to use Typeform library in my application, but I have a lot problems with it. After loading the js scripts, the Angular zone is wrong and I get this message:
Error: Zone.js has detected that ZoneAwarePromise
(window|global).Promise
has been overwritten. Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)
The code of my app.component.ts is:
import { Component, Inject, AfterViewInit} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import * as typeformEmbed from '@typeform/embed';
@Component({
selector: 'my-app',
template: `<div #my_typeform></div>`,
})
export class AppComponent implements AfterViewInit {
constructor(
@Inject(DOCUMENT) private document: Document
){}
ngAfterViewInit() {
const element = this.document.getElementById.call(document, 'my_typeform');
typeformEmbed.makeWidget(element, 'https://jonathan.typeform.com/to/zvlr4L', { onSubmit: () => console.log('Close') });
}
}
I have tried to run manually ngZone to ensure that it's ran inside Angular zone, but didn't work. In this case, app.component.ts was like
import { Component, Inject, AfterViewInit, NgZone} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import * as typeformEmbed from '@typeform/embed';
@Component({
selector: 'my-app',
template: `<div #my_typeform></div>`,
})
export class AppComponent implements AfterViewInit {
constructor(
@Inject(DOCUMENT) private document: any,
@Inject(NgZone) private ngZone: NgZone
){}
ngAfterViewInit() {
this.ngZone.run(() => {
const element = this.document.getElementById.call(document, 'my_typeform');
typeformEmbed.makeWidget(element, 'https://jonathan.typeform.com/to/zvlr4L', { onSubmit: () => console.log('Close') });
});
}
}
I have also tried to import 'zone.js/dist/zone-patch-rxjs' in my polyfill.ts file, but it didn't work either.
You can see a project with the minimal code to reproduce it in https://stackblitz.com/edit/angular-issue-repro2-daytbo
Any clue or help is really welcome!
Thanks in advance!