title: Angular2 component based on canvas : how to draw inside?
body: <p>I wrote a simple component based on a canvas, which I am resizing with an Input() property inside the companion class (TypeScript code). What I would like to do is to draw the canvas element inside the companion class, whose code is below : what is the simplest way to achieve that ? (Please, see the comment in the code : I would like to draw a blue rectangle inside the canvas from the constructor).</p>
  
  <pre><code>import {Component, View, Input} from 'angular2/core';
  
  @Component({
      selector: 'chess-diagram',
  })
  @View({
      template: `&lt;canvas class='chess-diag'
       [attr.width]='_size'
       [attr.height]='_size'&gt;&lt;/canvas&gt;`,
  })
  export class ChessDiagram {
      private _size: number;
  
      constructor(){
          this._size = 150;
          // Here I would like to draw a blue rectangle inside the canvas.
      }
  
      get size(){
          return this._size;
      }
  
      @Input () set size(newValue: number){
          this._size = Math.floor(newValue);
      }
  }
  </code></pre>