Show mdTooltip until clicked, hide when clicked again

I am trying to disable the mouseover effect and run mdTooltip on click and disable it on click again. Can this be done? I thought the .toogle () method would be the right tool for this, unfortunately, it works the other way around.

<div style="text-align: center;">
   <span matTooltip="Tooltip!" #tooltip="matTooltip" (click)="tooltip.toggle()">Test</span> 
</div>
Run codeHide result
+4
source share
1 answer

You should try using event.stopImmediatePropagation();

<span matTooltip="Tooltip!" 
  (mouseenter)="$event.stopImmediatePropagation()" 
  (mouseleave)="$event.stopImmediatePropagation()"
  #tooltip="matTooltip" (click)="tooltip.toggle()">Test</span> 

Plunger example

+2
source

Source: https://habr.com/ru/post/1687011/


All Articles