Created
August 29, 2019 18:23
-
-
Save CharlieGreenman/2cb9f75457da45a63d2b61333e5402d1 to your computer and use it in GitHub Desktop.
Directive for preloading Angular Modules
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 { Directive, ElementRef, HostListener } from '@angular/core'; | |
import { OnDemandPreloadService } from '@razroo/common/services'; | |
@Directive({ | |
selector: '[razrooPreload]' | |
}) | |
export class PreloadDirective { | |
constructor(private elementRef : ElementRef, | |
private onDemandPreloadService: OnDemandPreloadService) {} | |
@HostListener('mouseenter') | |
onMouseEnter() { | |
const pathName = this.elementRef.nativeElement.attributes.routerlink.value; | |
this.onDemandPreloadService.startPreload(pathName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment