[英]How to access dynamically added DOM element in Angular?
I am implementing the required constraint through $error
. 我正在通过$error
实现所需的约束。 I want to access The input element inside the from. 我要访问from中的输入元素。 ie {{frm.item.qid.$error.required}}
即{{frm.item.qid.$error.required}}
But since the form Object contains attribute q1
(value of item.qid
), frm.item
returns null
. 但是由于表单对象包含属性q1
( item.qid
值),因此frm.item
返回null
。
So How can I access, lets say frm.q1
(values for item.qid
are : q1,q2,q3, etc.) ? 那么,如何可以访问,可以说frm.q1
(值item.qid
是:Q1,Q2,Q3等)?
Here's the code: 这是代码:
<li ng-repeat = "item in questions">
<input name = {{item.qid}} type = "radio" ng-value = "item.option1" ng-model="item.selectedOption" required/>
<label ng-bind = "item.option1"></label>
<input name = {{item.qid}} type = "radio" ng-value = "item.option2" ng-model="item.selectedOption"/>
<label ng-bind = "item.option2"></label>
<input name = {{item.qid}} type = "radio" ng-value = "item.option3" ng-model="item.selectedOption"/>
<label ng-bind = "item.option3"></label>
<input name = {{item.qid}} type = "radio" ng-value = "item.option4" ng-model="item.selectedOption"/>
<label ng-bind = "item.option4"></label>
<label ng-show="">This is manadatory</label>
</li>
如果打印{{FRM}}后您的ul li
在DOM,你应该看看里面是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.