Marc Hughes


Home
Blog
Twitter
LinkedIn
GitHub
about
I am a developer from a bit west of Boston.

Dynamically drawing to an HTML canvas in angular.dart app

03 Jan 2014

Today, I wanted to dynamically create some content via an html canvas in my angular.dart application. After some tinkering, I figured out how.

First, you need to mix in the NgShadowRootAware class which will give you a onShadowRoot method. In this method, you can get a reference to your Canvas element that's created in the component's html. I save a reference to the context2D there.

Then, you can use the context2D to draw your view whenever content gets updated. For instance, I have the drawTimeline() call in the setter for the current day property.