When I write AngularJs, all I want to do is to write custom directives.
The power to create new HTML elements went to my head really quickly.
The directives can take HTML markup either using
template property, or
via external URL specified via
When AngularJs creates the color-pusher element it looks inside its
templateCache to see if there
is something under
color-pusher.tpl.html key. If not, it makes an Ajax request, received the template,
stores it in the cache and returns to the rendering function.
There is a work around: you can put stuff into
templateCache yourself, for example as part of the build
Then change your directive to depend on the template module
During the build step, concatenate both
widget.js together in any order (AngularJs dependency resolution
will sort out the order). That's it, you don't need separate template download.
Build using grunt and html2js
// html2js goal inside Gruntfile.js