Skip to content

Instantly share code, notes, and snippets.

@srfrnk
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save srfrnk/b808512b6b80eb36a50f to your computer and use it in GitHub Desktop.

Select an option

Save srfrnk/b808512b6b80eb36a50f to your computer and use it in GitHub Desktop.
Angular canvas directive. Demo at http://plnkr.co/edit/fMjsBr?p=preview
(function(angular) {
"use strict";
angular.module("ng.canvas", [])
.directive('canvas', ["$timeout",
function($timeout) {
return {
restrict: "E",
link: function(scope, elm , attrs ) {
scope[attrs.context2d||"context2d"]=elm[0].getContext("2d");
$timeout(function(){scope.$eval(attrs.init||"canvasInit()")});
}
};
}
]);
})(angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment