如何使用angularjs当名字字段。(点)以它来验证的形式?字段、如何使用、它来、形式

2023-09-13 03:07:43 作者:灯惞影雪

在我的表单中我有名字=Customer.Firstname一个输入标签,所以当我指的是angularjs其采取只作为顾客价值和.Firstname会不明身份的名称值。这里是我的code:

In my form I have a input tag with name="Customer.Firstname" so when i refer to name value in angularjs its taking only customer as the value and .Firstname is going unidentified. Here is my code:

<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>

下面我试图隐藏标签时文本框是我empty.How能做到这一点?

Here am trying to hide the label when the textbox is empty.How can i do that?

推荐答案

您可以使用bracket符号来访问键与圆点

You can use bracket notation to access keys with dot

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

演示:小提琴

这可以被改写为

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

演示:小提琴