Skip to content

Instantly share code, notes, and snippets.

@benlesh
Last active August 29, 2015 14:06
Show Gist options
  • Save benlesh/2a11d1b4d65006d6ade3 to your computer and use it in GitHub Desktop.
Save benlesh/2a11d1b4d65006d6ade3 to your computer and use it in GitHub Desktop.
Angular 1.3.0-beta.19 SVG custom element
/**
creates a circle in the upper left corner of its container
with the given radius. `<custom-circle radius="10"/>`
*/
app.directive('customCircle', function(){
return {
// the following two configuration options are
// required for SVG custom elements.
templateNamespace: 'svg',
replace: true,
// NOTE: ng-attr- style binding is used to prevent SVG validation
// error messages.
template: '<circle ng-attr-cx="{{radius}}" ng-attr-cy="{{radius}}" ng-attr-r="{{radius}}"/>',
// everything else as normal
scope: {
radius: '@',
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment