title: How to create an Angular 2 canvas-based component that responds to being resized?
body: <p>I want to create a component whose view is simply a canvas element. I want this component to:</p>
  <ul>
  <li>Fill whatever element it is placed with the canvas</li>
  <li>Determine its width and height during its initialization process</li>
  <li>Know when it has been resized, figuring out its new height and width, and responding appropriately.</li>
  </ul>
  <p>I figure I can achieve the first part by specifying the width and height of the canvas in my component's template as 100%, like this:</p>
  <pre class="lang-js prettyprint-override"><code>@Component({
    selector: 'canvas-component',
    template:'&lt;canvas style=&quot;width:100%; height:100%&quot;&gt;&lt;/canvas&gt;'
  })
  </code></pre>
  <p>But I have no idea how to go about the second or third parts.</p>
  <p>The ultimate goal is to be able to draw shapes in the canvas that take up the same relative size of the canvas, regardless of its size. As an example, I'd want to draw a circle with a diameter of 3/4 the width of the canvas - so if the canvas grows or shrinks, the circle should be re-drawn, growing or shrinking as well.</p>
  <p>I don't know if it matters, but I'm making the web app in Typescript.</p>
  <p>Does anyone know of a good way of achieving this? I'm looking for doing it the most &quot;Angular way&quot; possible, since this is a personal project I'm using to learn Angular 2.</p>
  <p>Thanks in advance!</p>