angular js指令更改Color svg元素

时间:2017-12-28 16:56:58

标签: javascript angularjs svg

我已成功正确加载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);

        }
    }
}]);

0 个答案:

没有答案