问题:当我单击SVG图形中的test
元素时,我想运行<path>
函数。现在,当我点击元素时没有任何反应。但是 - 当我用ng-click
替换onclick="alert('success')"
时,警报可以正常工作。有什么建议吗?
在我的代码中......
我的HTML部分...
<div ng-controller="converter">
<embed src="/image.svg">
<!--This button successfully runs the test function-->
<button ng-click="test()">Test</button>
</div>
我的app.js ...
var app = angular.module('app', []);
app.controller('converter', ['$scope', '$http', function($scope, $http){
$scope.test = function(){
console.log("this click event is working");
}
}]);
我的嵌入式SVG文件的一部分...
<rect id="e1-1-2" data-name="e1-1" class="cls-35" x="14" y="106" width="57" height="22" ng-click="test()"/>
(以下是完整代码,感兴趣的人:https://github.com/cwklausing/angular_guitar)
答案 0 :(得分:4)
将其包裹在svg
中<svg width="400" height="110">
<rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" ng-click="test()" />
</svg>
这是工作Plunker