Created
December 16, 2021 16:07
-
-
Save peterblazejewicz/1193a08fe09a878c12616619a6dec157 to your computer and use it in GitHub Desktop.
Template resolver (angularjs to angular) example
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
@Injectable() | |
export class TemplateResolver implements Resolve<string> { | |
constructor( | |
private templateService: TemplateService, | |
@Inject('$templateCache') private $templateCache: any | |
) {} | |
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | |
const templateUrl = route.data.templateUrl; | |
return this.templateService | |
.getTemplate(templateUrl) | |
.pipe(tap(template => this.$templateCache.put(templateUrl, template))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment