Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当名称字段中有。(点)时,如何使用angularjs验证表单?_Javascript_Jquery_Angularjs - Fatal编程技术网

Javascript 当名称字段中有。(点)时,如何使用angularjs验证表单?

Javascript 当名称字段中有。(点)时,如何使用angularjs验证表单?,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,在我的表单中,我有一个名为name=“Customer.Firstname”的输入标记,因此当我在angularjs中引用name值时,它只将Customer作为值,而.Firstname将无法识别。 这是我的密码: <label class="label_block" ng-hide="ApplicantDetails.Customer.FirstName.$error.required || ApplicantDetails.Customer.FirstName.$error.patt

在我的表单中,我有一个名为name=“Customer.Firstname”的输入标记,因此当我在angularjs中引用name值时,它只将Customer作为值,而.Firstname将无法识别。 这是我的密码:

<label class="label_block" ng-hide="ApplicantDetails.Customer.FirstName.$error.required || ApplicantDetails.Customer.FirstName.$error.pattern">FirstName</label>
<span class="clearable">
    <input class="textbox"  type="text" name="Customer.FirstName" ng-model="Customer.FirstName" ng-init="Customer.FirstName='@Model.Customer.FirstName'" value="@Model.Customer.FirstName" ng-pattern="/^([a-zA-Z-']{1,30})$/" required="required"/>
</span>
FirstName
当文本框为空时,我试图隐藏标签。我该怎么做

您可以使用点访问密钥

<label class="label_block" ng-hide="ApplicantDetails['Customer.FirstName'].$error.required || ApplicantDetails['Customer.FirstName'].$error.pattern">FirstName</label>
FirstName
演示:

这可以改写为

<label class="label_block" ng-show="ApplicantDetails['Customer.FirstName'].$valid">FirstName</label>
FirstName

演示:

您可以指定与ng型号不同的名称。它可能是CustomerFirstName。或者可以使用数组表示法,比如Form['Customer.FirstName'],如果文本框名称中有括号,比如
,那么可能会出现重复的情况,您可以想象这个文本框是由某个html元素上的ng repeat属性呈现的,而该元素又有这个文本框。在这种情况下,括号符号是如何工作的?@Arun P Johny:我有一个类似的问题,我在。请看一看。