Custom tooltip with dynamic html in Angular Tooltip component
19 Sep 20222 minutes to read
Tooltip loads HTML pages via HTML tags such as iframe, video, and map using the content
property, which supports both string and HTML tags.
To load an iframe
element in tooltip, set the required iframe in the content
of tooltip while initializing the tooltip component. Refer to the following code.
content= '<iframe src="https://www.syncfusion.com/products/essential-js2"></iframe>
import { Component, ViewEncapsulation } from '@angular/core';
import { TooltipComponent } from '@syncfusion/ej2-angular-popups';
@Component({
selector: 'my-app',
template: `
<div id="tooltipContent">
<div class="content">
<ejs-tooltip cssClass='e-tooltip-css' position='BottomCenter' opensOn='Click'>
<!-- iframe element -->
<ng-template #content>
<iframe src="https://www.syncfusion.com/products/essential-js2"></iframe>
</ng-template>
<button ejs-button class="text" id="iframeContent" cssClass='e-outline' isPrimary=true>Embedded Iframe</button>
</ejs-tooltip>
</div>
</div>`,
encapsulation: ViewEncapsulation.None,
})
export class AppComponent {
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { TooltipModule } from '@syncfusion/ej2-angular-popups';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { AppComponent } from './app.component';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule,
TooltipModule,ButtonModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);