Svg 将角度插值ID传递给函数
我一直在尝试传递ng repeat生成的SVG元素的ID 每个都有一个cx、cy和一个id:Svg 将角度插值ID传递给函数,svg,angularjs-ng-repeat,angularjs-interpolate,Svg,Angularjs Ng Repeat,Angularjs Interpolate,我一直在尝试传递ng repeat生成的SVG元素的ID 每个都有一个cx、cy和一个id: $scope.circles = [ {cx:25, cy:40, id:1}, {cx:55, cy:40, id:2}, {cx:75, cy:40, id:3}]; 在HTML中插入以下代码: <circle ng-repeat= "c in circles" ng-attr-cx={{c.cx}} ng-attr-cy={{c.cy}} ng-attr-id={{c
$scope.circles = [
{cx:25, cy:40, id:1},
{cx:55, cy:40, id:2},
{cx:75, cy:40, id:3}];
在HTML中插入以下代码:
<circle ng-repeat= "c in circles"
ng-attr-cx={{c.cx}}
ng-attr-cy={{c.cy}}
ng-attr-id={{c.id}}
r="6" stroke="black" stroke-width="3" fill="red"
ng-mouseover ="changeR(this)" />
这会产生一个带有“[object object]”的警报,尽管我认为我坚持了小提琴中的模式,它在小提琴中工作,在警报窗口中以文本形式通过id。当我直接传递插值id号函数时,它可以很好地改变我想要的半径(我通过硬编码id得到元素,半径在这一个圆上改变…)
如何将这个ID传递到后端,以便获取元素并让它有效地修改自己的属性?如果这是一个页面加载问题,并且没有及时注册ID,为什么鼠标悬停事件不会处理完全加载的页面
$scope.changeR= function (id){
alert(id);
var circleChange = document.getElementById(id);
circleChange.setAttribute("r", "20");
}