Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/demo/app/tooltip-hint/tooltip-hint.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ export class TooltipHintDemoComponent implements OnInit {
constructor() { }

ngOnInit(): void { }

alertar(e) {
alert(`Inner HTML: ${e.target.innerHTML}`);
}
}
2 changes: 1 addition & 1 deletion src/demo/app/tooltip-hint/tooltip-hint.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</plex-button>
<plex-button class="ml-1" size="sm" type="danger"
hint="¿Sabías que... el hint es un texto que sugiere acciones o indica alguna novedad? Además tiene soporte multilínea."
position="above">
position="above" (click)="alertar($event);">
hint
</plex-button>
</plex-title>
Expand Down
10 changes: 7 additions & 3 deletions src/lib/hint/hint.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { MatTooltip } from '@angular/material/tooltip';
import { Component, OnInit, AfterViewInit, Host, Self, Optional, Input, ElementRef, ChangeDetectorRef } from '@angular/core';
import { Component, OnInit, AfterViewInit, Input, ChangeDetectorRef, HostListener } from '@angular/core';

@Component({
selector: 'plex-hint',
template: `
<a (click)="$event.preventImmediatePropagation()" href="javascript:void(0)" *ngIf="position" class="hint-container" [matTooltip]="content" [matTooltipPosition]="position">
<a href="javascript:void(0)" *ngIf="position" class="hint-container" [matTooltip]="content" [matTooltipPosition]="position">
<plex-icon class="hint" [name]="icon" type="default"></plex-icon>
</a>
`
Expand Down Expand Up @@ -32,4 +31,9 @@ export class HintComponent implements OnInit, AfterViewInit {
this.cdr.detectChanges();
}

// Si el elemento que tiene la directiva [hint] tiene un evento (click), este se ejecutará, guste o no.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y si no lo tiene? pincha!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jaja ahí se fixeó eso!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liquid36 decime si ves bien el fix 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esta bien, pense que hostElement era una componente Angular, pero es un elemento del DOM, así que se ve que siempre tiene click.

@HostListener('click', ['$event']) onClick() {
this.hostElement.click();
}

}