File

src/dialog/tooltip/tooltip.component.ts

Description

Extend the Dialog component to create a tooltip for exposing content.

Extends

Dialog

Metadata

selector ibm-tooltip

Index

Properties
Methods
HostBindings

HostBindings

style.display
style.display:
Default value : inline-block

Methods

onDialogInit
onDialogInit()

Check whether there is a template for the Tooltip content.

Returns : void

Properties

Public hasContentTemplate
hasContentTemplate:
Default value : false

Value is set to true if the Tooltip is to display a TemplateRef instead of a string.

import {
	Component,
	TemplateRef,
	HostBinding
} from "@angular/core";
import { Dialog } from "./../dialog.component";

/**
 * Extend the `Dialog` component to create a tooltip for exposing content.
 */
@Component({
	selector: "ibm-tooltip",
	template: `
		<div
			#dialog
			[id]="dialogConfig.compID"
			role="tooltip"
			tabindex="0"
			class="bx--tooltip bx--tooltip--shown">
			<span class="bx--tooltip__caret" aria-hidden="true"></span>
			<ng-template
					*ngIf="hasContentTemplate"
					[ngTemplateOutlet]="dialogConfig.content"
					[ngTemplateOutletContext]="{tooltip: this}">
			</ng-template>
			<p
				*ngIf="!hasContentTemplate">
				{{dialogConfig.content}}
			</p>
		</div>
		`
})
export class Tooltip extends Dialog {
	@HostBinding("style.display") style = "inline-block";
	/**
	 * Value is set to `true` if the `Tooltip` is to display a `TemplateRef` instead of a string.
	 */
	public hasContentTemplate = false;

	/**
	 * Check whether there is a template for the `Tooltip` content.
	 */
	onDialogInit() {
		this.hasContentTemplate = this.dialogConfig.content instanceof TemplateRef;
	}
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""