Make visible all tooltips at the same time - MatTooltip Angular

Viewed 370

Is there any way to display all the tooltips at the same time in angular matTooltip. We can do this like below, but it needs to declare all the viewChild for doing that,

@ViewChild('tooltip', { static: true })tooltip:MatTooltip;

There are more than 50 mat-tooltip elements in the app. Is there are any easy way to do that in angular.

1 Answers

There's ViewChildren

Something like

@ViewChildren(MatToolTip) tooltips: QueryList<MatTooltip>;

showAll(): void {
  this.tooltips.forEach(toolTip => toolTip.show())
}

StackBlitz example

Related