[英]AngularJS and SVG--using ng-click on a <rect> element?
Problem: I want to run the test
function when I click on a <path>
element in an SVG graphic. 问题:单击SVG图形中的
<path>
元素时,我想运行test
功能。 Right now nothing happens when I click the element. 现在,当我单击该元素时,什么也没有发生。 HOWEVER--when I replace
ng-click
with onclick="alert('success')"
the alert works fine. 但是,当我用
onclick="alert('success')"
替换ng-click
,警报效果很好。 Any suggestions? 有什么建议么?
In my code... 用我的代码...
section of my html... 我的html部分...
<div ng-controller="converter">
<embed src="/image.svg">
<!--This button successfully runs the test function-->
<button ng-click="test()">Test</button>
</div>
my app.js... 我的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");
}
}]);
part of my embedded SVG file... 我的嵌入式SVG文件的一部分...
<rect id="e1-1-2" data-name="e1-1" class="cls-35" x="14" y="106" width="57" height="22" ng-click="test()"/>
(Here's the full code, for those interested: https://github.com/cwklausing/angular_guitar ) (这是完整的代码,对于那些感兴趣的人: https : //github.com/cwklausing/angular_guitar )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.