我正在研究离子角度。我想User Profile
在我的输入字段为First Name
、Last Name
、Cell Phone
等的页面上执行验证Password
。
我想要实现的是在最后一个字段的底部一次显示单个错误消息。通过使用ng-messages
,我为每个字段获取单独的消息,但我只想显示第一条错误消息。
以下是我的html代码
<!-- input fields defined -->
<label class="item item-input item-stacked-label">
<span class="input-label">First Name</span>
<input type="text" placeholder="jack" name="fName" ng-model="userData.fName" required="required" ng-focus="clearValidation();" ng-class="{ 'errorCls' : profileInfoForm.fName.$invalid, 'noErrorCls' : profileInfoForm.fName.$valid}"/>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Last Name</span>
<input type="text" placeholder="dow" name="lName" ng-model="userData.lName" required="required" ng-focus="clearValidation();" ng-class="{ 'errorCls' : profileInfoForm.lName.$invalid, 'noErrorCls' : profileInfoForm.lName.$valid}"/>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Cell Phone Number</span>
<input type="text" placeholder="185-728-4380" name="cellPhone" ng-model="userData.cellPhone" required="required" />
</label>
<!-- input fields validations defined -->
<div ng-messages="(profileInfoForm.$submitted || profileInfoForm.fName.$dirty) && profileInfoForm.fName.$error">
<span ng-message="required">Please enter first name</span>
</div>
<div ng-messages="(profileInfoForm.$submitted || profileInfoForm.lName.$dirty) && profileInfoForm.lName.$error">
<span ng-message="required">Please enter last name</span>
</div>
<div ng-messages="(profileInfoForm.$submitted || profileInfoForm.cellPhone.$dirty) && profileInfoForm.cellPhone.$error">
<span ng-message="required">Please enter cellphone number</span>
</div>
我该怎么做?需要你的帮助。
谢谢你。