简体   繁体   English

如何将AngularJS与SVG标签一起使用? 我想从angular传递SVG标签中的参数

[英]How do I use AngularJS with SVG tag ? I want to pass a parameter in SVG tag from angular

I want to take input from user through AngularJS and aapply it on a SVG circle tag. 我想通过AngularJS从用户那里获取输入,并将其应用到SVG圆标记上。 Is there anyone who could help me with this? 有谁可以帮助我吗?

What I am doing is here: 我在做什么在这里:

<div class="app" ng-app>
  <div ng-controller="ctrlSizing">
    <label>Radius:
      <input ng-model="rad" type="number" placeholder="How about 300?">
    </label>
  </div>
</div>
<div style="height: 800; width: 500; position:absolute; left: 100px;top: 100px;">
  <svg width="500" height="500" visibility="visible">
    <circle id="circle1" cx="150" cy="150" r="getRad()" stroke="black" stroke-width="2" fill="grey" />
  </svg>
</div>

Use ng-attr-r instead of r attribute on circle. 在圆上使用ng-attr-r而不是r属性。

Markup 标记

<div data-ng-controller="AppCtrl" id="ctrl">
    <input data-ng-model="rad"> {{rad}}
    <div style="height: 800; width: 500; position:absolute; left: 100px;top: 100px;">
            <svg width="500" height="500" visibility="visible" >
                <circle id="circle1" cx="150" cy="150" ng-attr-r="{{rad}}" stroke="black" stroke-width="2" fill="grey" />
            </svg>
    </div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM