use below command to install the package
npm install p_iframe_bootstrapper_ts
Usage for angular project
import { Component, ElementRef, AfterViewInit, ViewChild } from '@angular/core';
import { payverisIframeInitalizer, PayverisIframeInitializerOptions } from 'p_iframe_bootstrapper_ts';
@Component({
template: `<iframe #iframeElement src="https://www.<app_url>.com" frameborder="0"></iframe>`
})
export class AppComponent implements AfterViewInit {
/* The `@ViewChild('iframeElement')` decorator is used to query and obtain a reference to the
`iframeElement` element in the component's template. The `iframeElement` property is then declared
with the `ElementRef` type, which allows access to the underlying DOM element of the iframe. This
reference is used in the `ngAfterViewInit` lifecycle hook to attach an `onload` event handler to
the iframe element. */
@ViewChild('iframeElement') iframeElement!: ElementRef;
/**
* The ngAfterViewInit function sets an onload event listener on an iframe element and calls the
* onLoadIframe function when the iframe has finished loading.
*/
ngAfterViewInit() {
this.iframeElement.nativeElement.onload = () => this.onLoadIframe();
}
/**
* The function initializes a Payveris iframe with specified options.
*/
onLoadIframe() {
const options: PayverisIframeInitializerOptions = {
loggingEnabled: true,
isBillCenter: true
};
payverisIframeInitalizer.init(options, this.iframeElement.nativeElement);
}
}