Reputation: 115
I want to take input from user through AngularJS and aapply it on a SVG circle tag. 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>
Upvotes: 0
Views: 802
Reputation: 5572
Use ng-attr-r
instead of r
attribute on circle.
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>
Upvotes: 2