Skip to content

Instantly share code, notes, and snippets.

@peterblazejewicz
Created December 16, 2021 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterblazejewicz/1193a08fe09a878c12616619a6dec157 to your computer and use it in GitHub Desktop.
Save peterblazejewicz/1193a08fe09a878c12616619a6dec157 to your computer and use it in GitHub Desktop.
Template resolver (angularjs to angular) example
@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