Skip to content

Instantly share code, notes, and snippets.

@justindujardin
Created November 11, 2017 22:07
Show Gist options
  • Save justindujardin/0e9688be49b7d324a88d4a827669bbc4 to your computer and use it in GitHub Desktop.
Save justindujardin/0e9688be49b7d324a88d4a827669bbc4 to your computer and use it in GitHub Desktop.
canvas component
import {
AfterViewInit, Component, ElementRef, OnDestroy, ViewChild
} from '@angular/core';
@Component({
selector: 'cool-gl',
template: `
<canvas #lookupTag></canvas>`
})
export class CoolGLComponent implements AfterViewInit, OnDestroy {
@ViewChild('lookupTag') canvasRef: ElementRef;
// Called after the view is totally initialized and the "View query"
// from `@Viewchild` has resolved.
ngAfterViewInit(): void {
const canvas: HTMLCanvasElement = this.canvasRef.nativeElement;
console.log('found yer canv(ass) like whoa: ' + canvas);
// Do yer wiring up three.js here.
}
ngOnDestroy(): void {
// Clean up your things, jerk.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment