Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This example works, but this is not the type of solution as intended.
How do I use the template line to do this?

What I have tried:

JavaScript
// WERKEND 160607 22:30

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: ''
})
export class AppComponent {

    canvas: HTMLCanvasElement;
    ctx: any;
  
  constructor () {
    
    this.canvas =  <HTMLCanvasElement>document.createElement("canvas");
    this.canvas.width = 400;
    this.canvas.height = 400;
    document.body.appendChild(this.canvas);
    this.ctx = this.canvas.getContext("2d");

    this.canvas.style.setProperty("background", "red", null);
    this.canvas.style.setProperty("border-width", "thick", null);
    this.canvas.style.setProperty("border-color", "blue", null);
    this.canvas.style.setProperty("border-style", "dotted", null);

    this.ctx.beginPath();
    this.ctx.moveTo(25, 25);
    this.ctx.lineTo(375, 375);
    this.ctx.stroke();
  }
}
Posted
Updated 8-Jun-16 9:49am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900