在 angular 中访问名称中包含特殊字符的输入
accessing input with special characters in name in angular
我有动态分配名称的输入。结果我输入了像
这样的名字
name="Athlete/Guardian_firstName"
对于输入没问题,但由于此记录
,验证不起作用
medForm.Athlete/Guardian_firstName.$invalid
由于斜线“/”,对于 angular 的 ng-class 无效。 (medForm 是表格的名称)。是否有任何其他方法可以从 angular 中的表单访问输入,因此具有任何特殊字符的输入都可以工作?
<div class="form-group" ng-class="{ 'has-error': medForm.Athlete/Guardian_firstName.$invalid }">
<label for="firstName" class="col-md-3 control-label">First Name</label>
<div class="col-md-9">
<input type="text" class="form-control" id="firstName" name="Athlete/Guardian_firstName" required ng-model="firstName">
</div>
</div>
试试这个方法:
medForm['Athlete/Guardian_firstName'].$invalid
我有动态分配名称的输入。结果我输入了像
这样的名字name="Athlete/Guardian_firstName"
对于输入没问题,但由于此记录
,验证不起作用由于斜线“/”,medForm.Athlete/Guardian_firstName.$invalid
对于 angular 的 ng-class 无效。 (medForm 是表格的名称)。是否有任何其他方法可以从 angular 中的表单访问输入,因此具有任何特殊字符的输入都可以工作?
<div class="form-group" ng-class="{ 'has-error': medForm.Athlete/Guardian_firstName.$invalid }">
<label for="firstName" class="col-md-3 control-label">First Name</label>
<div class="col-md-9">
<input type="text" class="form-control" id="firstName" name="Athlete/Guardian_firstName" required ng-model="firstName">
</div>
</div>
试试这个方法:
medForm['Athlete/Guardian_firstName'].$invalid