Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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