I've developed AngularJS directives to add rectangle into SVG document:
<svg version="1.1" width="200" height="100">
<g>
<!-- Works -->
<g dir-rect1="" viz-settings="settings.rect1" />
<!-- Doesn't work -->
<g dir-rect2="" viz-settings="settings.rect2" />
</g>
The only difference is between the directives is that the dir-rect1 directive doesn't use replace and the dir-rect2 directive use:
app.directive('dirRect2', function($compile) {
return {
restrict: 'AE',
scope: {
vizSettings: '=',
},
replace:true, // <--- DOESN'T WORK
template: '<rect fill="{{vizSettings.fill}}" stroke="{{vizSettings.fill}}" width="{{vizSettings.width}}" height="{{vizSettings.height}}" />',
link: function($scope, elem, attr, ctrl) {
console.debug($scope);
}
};
});
Why when I use replacing in my dirRect2 directive, I cannot see a rect? It seems that generated code is right in both cases. You can see example on plunker.