[SOLVED]
I created a simple SVG directive using angular 1.3-beta which features a "type: 'svg'" for directive. The code is straightforward (see Plunker http://plnkr.co/edit/vgElXdWXvfH0faH0qKHk?p=preview - updated with solution):
- Create a SVG element containing a square
- when the square is clicked, a class is added to it (fill with red)
- ISSUE: the class is correctly added to the SVG square element but it is ignored and the square remains black.
Here is the js part:
var app = angular.module('app', [])
.directive('svgDirective', function () {
return {
template: '<svg xmlns:xlink="http://www.w3.org/1999/xlink"> <g ng-transclude> </g> </svg>',
transclude: true,
type: 'svg',
replace: true
};
})
.directive('svgSquare', function() {
return {
template: '<rect width=100 height=100></rect>',
type: 'svg',
replace: true,
link: function (scope, element, attrs) {
element.on('click', function () {
element.addClass("selected");
});
}
};
});
and the CSS:
.selected {
fill: '#f00'; --> SOLUTION: no quotation mark: fill: #f00;
}