我已成功正确加载svg。我想改变svg rect的颜色。我创建了这个指令,但它不起作用:
directives.js:
angular.module('svgApp').directive('place', ['$compile', function ($compile) {
return {
restrict: 'A',
scope: true,
link: function (scope, element, attrs) {
scope.elementId = element.attr("class");
scope.placeClick = function () {
scope.presskey(scope.elementId);
alert(scope.elementId);
};
element.attr("ng-click", "placeClick()");
element.attr("ng-attr-fill", "yellow");
element.removeAttr("place");
$compile(element)(scope);
}
}
}]);