Created
May 10, 2021 08:38
-
-
Save nirkaufman/44efac9c19e0e20ef84c66d7c1580462 to your computer and use it in GitHub Desktop.
This file contains 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
// Concept | |
@Directive({ | |
selector: 'introTip' | |
}) | |
class IntroTipDirective implements Oninit{ | |
@Input('introTip') key: string; | |
constructor(private hostElement: ElementRef, | |
private interService; | |
) {} | |
onInit() {this.interService.addStep(this.key, this.hostElement.nativeElement)} | |
} | |
interface Step { | |
label: string; | |
intro: string; | |
element: HTMLElement; | |
} | |
class IntroService { | |
readonly steps: Map<string, Step>; | |
addStep(key: string, elemnt: HTMLElement) { | |
this.steps.get(key).element = elemnt; | |
} | |
start() { | |
introJs.start() | |
} | |
} | |
// Concept! | |
import {AfterViewInit} from "@angular/core"; | |
// service | |
{ | |
TIP_1: "what to display", element, | |
TIP_2: "what to display 2", element, | |
} | |
` | |
<div></div> | |
<button introTip="TIPS_TIP_1">click</button> | |
<input introTip= "TIPS_TIP_2" type="text" /> | |
` | |
class PageComponent implements AfterViewInit, OnDe{ | |
constructor(private introService) { | |
} | |
ngAfterViewInit() { | |
this.introService.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment