src/dialog/tooltip/tooltip.component.ts
Extend the Dialog component to create a tooltip for exposing content.
| selector | ibm-tooltip |
Properties |
|
Methods |
HostBindings |
| style.display |
style.display:
|
Default value : inline-block
|
|
Defined in src/dialog/tooltip/tooltip.component.ts:34
|
| onDialogInit |
onDialogInit()
|
|
Defined in src/dialog/tooltip/tooltip.component.ts:43
|
|
Check whether there is a template for the
Returns :
void
|
| Public hasContentTemplate |
hasContentTemplate:
|
Default value : false
|
|
Defined in src/dialog/tooltip/tooltip.component.ts:38
|
|
Value is set to |
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;
}
}