Created
September 26, 2016 14:40
-
-
Save vsakaria/ccc878c06592403bb2e16b8c91c7cf05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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