验证输入与AngularJS包含名称括号 [英] validate input with name containing brackets in AngularJS

查看:110
本文介绍了验证输入与AngularJS包含名称括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有含支架的名字,例如一个表单输入:

I have a form input with names containing brackets, e.g.:

<form name="my_form">  
    <input type="text" name="my_form[email]" ng-model="email" ng-class="'mycssclass': my_form.my_form[email].$invalid">
</form>

所以,问题是,角度不适用,因为我的输入(my_form [邮件])的名称的CSS类,是正确的符号引用我的输入角。

So, the problem is that Angular is not applying that css class because of the name of my input (my_form[email]), is that the correct notation to reference my input in Angular.

下面是一个普拉克:
http://plnkr.co/edit/t7PEilV9maNYGnVYnTDc?p=$p$pview

推荐答案

引用输入包含括号的名称的方法是使用括号符号,就像这样:

The way to reference an input with a name containing brackets is using brackets notation, like this:

my_form['my_form[email]'].$invalid

这篇关于验证输入与AngularJS包含名称括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆