我有以下代码,我使用AngularJS验证电子邮件输入。这是一个ng-repeat,我跟踪这个人使用&data; tulifiateSelect.cusomter_no'。
我将customer_no附加到电子邮件输入的名称,以确保它们都具有唯一的名称。 如何在span.error-msg ngShow表达式中引用此名称?我尝试了几种不同的方法但没有成功。
提前致谢。
<form name="registrantForm" ng-submit="submitRegistrantForm()" novalidate>
<div class="session-registrant-field field-email" ng-if="data.affiliateSelect.ask_email == 'Y'">
<label for="">Email
<span class="error-msg" ng-show="registrantForm.$submitted || registrantForm.(email+'-'+data.affiliateSelect.customer_no).$touched">
<span ng-show="registrantForm.(email+'-'+data.affiliateSelect.customer_no).$error.required">Please provide your email.</span>
<span ng-show="registrantForm.(email+'-'+data.affiliateSelect.customer_no).$error.email">Please enter a valid email.</span>
</span>
</label>
<input type="email" name="email-{{data.affiliateSelect.customer_no}}" id="email-{{data.affiliateSelect.customer_no}}" value"" ng-model="affiliateEmail" required>
</div>
</form>
答案 0 :(得分:0)
registrantForm['email-' + cartPerf.perf_no + data.affiliateSelect.customer_no].$error.required
以上是我需要使用的正确语法。