angular-canvas-painter
angular-canvas-painter copied to clipboard
How to access canvas content in my angular controller?
Hi. Thank you for this great directive.
I was able to integrate it in my project, but I'm having trouble acessing the canvas content in my Angular controller.
I need to convert the canvas to an image and save it in my database via API.
Thank you in advance, Rodrigo
My actual question is: does the directive expose an angular model of the canvas content, or do I need to take care of that with pure JavaScript?
Hey, this is not yep implemented. At the moment you have to access the canvas with its id to get the context/image. But there will be an update soon (next few days), which will provides the context in an easier way.
Cherrs Phil
hi @pwambach, can you give us info on "which will provides the context in an easier way." accessing image data ?
thanks
Hey, sorry, have been a bit lazy on this one. For now the only option is to pass a custom Id (in the options object) to the canvas and access it with document.getElementById('<customId>')
in your controller.
From there you can get the context, dataUrl or whatever.
I was thinking about returning the dataUrl as a scope variable on which you can set a watch function in the controller? But I am not sure if this is the best solution.
What do you need from the canvas? the canvas element, context or dataURL? And how do you want to access it.
Another solution could perhaps be a callback which provides the canvas element as parameter.