There is a templateNamespace property you can set to svg:
templateNamespace
svg
module.directive('testrect', function() { return { restrict: 'E', templateNamespace: 'svg', template: '', replace: true }; });
Here is a link to the documentation.