Skip to content

Instantly share code, notes, and snippets.

@vsakaria
Created September 26, 2016 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsakaria/ccc878c06592403bb2e16b8c91c7cf05 to your computer and use it in GitHub Desktop.
Save vsakaria/ccc878c06592403bb2e16b8c91c7cf05 to your computer and use it in GitHub Desktop.
import { Component, Input, OnInit} from "@angular/core";
import { TooltipService } from "./tooltip.service";
import { Sanitizer } from "../../../utils/eh.sanitizer.util.service";
import { SafeHtml } from "@angular/platform-browser";
@Component({
selector: "tooltip",
templateUrl: "./tooltip.component.html",
styles: [`
:host {
display: block;
}
.info {
width: 14px;
cursor: pointer
}
`]
})
export class TooltipComponent implements OnInit {
@Input() showExplanation: boolean;
@Input() assestId: number;
explanation: string;
safeExplanation: SafeHtml;
constructor(public tooltipService: TooltipService, private sanitizer: Sanitizer) {}
ngOnInit() {
this.safeExplanation = this.sanitizer.sanitizeText("");
}
showTooltip() {
this.getExplanation(this.assestId);
}
getExplanation(id: number) {
this.tooltipService.getExplanation(id)
.subscribe((response) => {
this.explanation = response.explanation || "";
this.safeExplanation = this.sanitizer.sanitizeText(this.explanation);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment