I want to have a component that renders an arbitrary number of canvas elements that contain images or videos or whatever. Sometimes there will be one image. Other times I'll want to have two or three side-by-side. Maybe there's a button to toggle between one or two images.
So my component looks roughly like this:
@Component({
selector: 'canvas-container',
template: `<div *ngFor="let canvas of canvases">???</div>`
})
export class CanvasContainerComponent {
canvases: HTMLCanvasElement[] = [];
addCanvas(image) {
const canvas = <HTMLCanvasElement> document.createElement('canvas');
// some stuff to do with sizing and drawing
this.canvases.push(canvas);
}
}
So another component will call the addCanvas method, or the canvases will be passed in as an @Input.
How can I wrestle with Angular 2 to then render these canvases that are stored as HTMLCanvasElement variables? Using {{canvas}} just displays the string form of the element: [object HTMLCanvasElement].
Or is there a better way to approach this whole endeavour?