Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
¿Cómo copiar contenido de la información sobre herramientas?

Estoy tratando de implementar una directiva de información sobre herramientas personalizada con Angular CDK. Me gustaría que la información sobre herramientas permanezca abierta. Por ejemplo, cuando aparece una información sobre herramientas, ¿cómo puedo copiar su contenido?

StackBlitz https://stackblitz.com/edit/angular-nms-tooltip?file=src%2Fapp%2Ftooltip%2Ftooltip.component.ts

tooltip.directiva.ts

 import { ComponentRef, Directive, ElementRef, HostListener, Input, OnInit, } from '@angular/core'; import { Overlay, OverlayPositionBuilder, OverlayRef, } from '@angular/cdk/overlay'; import { ComponentPortal } from '@angular/cdk/portal'; import { TooltipComponent } from './tooltip.component'; @Directive({ selector: '[tooltip]' }) export class TooltipDirective implements OnInit { @Input('tooltip') data: string; private overlayRef: OverlayRef; constructor( private overlay: Overlay, private overlayPositionBuilder: OverlayPositionBuilder, private elementRef: ElementRef ) {} ngOnInit(): void { const positionStrategy = this.overlayPositionBuilder .flexibleConnectedTo(this.elementRef) .withPositions([ { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom', offsetY: -8, }, ]); this.overlayRef = this.overlay.create({ positionStrategy }); } @HostListener('mouseenter') show() { const tooltipRef: ComponentRef<TooltipComponent> = this.overlayRef.attach( new ComponentPortal(TooltipComponent) ); tooltipRef.instance.data = this.data; } @HostListener('mouseout') hide() { this.overlayRef.detach(); } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!