0
私は自分のフォームで電子メールの検証を行っています。ユーザーがすでに登録されている場合は、アラートが表示され、null値のフォームがリセットされます。私はアラートメッセージとデータをフォームに保持する必要があります。 ありがとうございます。 https://plnkr.co/edit/WhdRmJmLs69yaf6Q2uYI?p=previewanglejsで検証エラーの後にフォームに値を保持する方法
<div class="form-group">
<label class="control-label col-sm-2" for="firstName">First Name:</label>
<div class="col-xs-4">
<input type="text" class="form-control" id="firstName" ng-disabled="!edit" name="firstName" ng-model="user.firstName" ng-required="true">
<span style="color:red" ng-show="userForm.myName.$touched && userForm.myName.$invalid">Please enter a First Name</span>
</div>
<label class="control-label col-sm-2">Email:</label>
<div class="col-xs-4"><input type="email" id="email" class="form-control" ng-disabled="!edit" name="email" ng-model="user.email" ng-required="true">
<span style="color:red" ng-show="userForm.email.$touched && userForm.email.$invalid">Please enter valid email ID</span>
</div>
</div>
<div class="panel-footer">
<button type="button" ng-click='edit=!edit'id="Edit" ng-show="!edit" class="btn btn-default" >Edit</button>
<button ng-show="edit" id="save" type="submit" ng-click='addOrModifyUser(user)' class="btn btn-default"
ng-disabled="userForm.$invalid">Save
</button>
<a ng-if="user.accountId" ui-sref="account.locations.contacts({accountId: user.accountId})">
<button type="type" class="btn btn-default">Cancel</button>
</a>
</div>
I?p =プレビュー
$ http呼び出しの前に別の変数に保存して、一意性を検証します。 –
あなたのプラークは、あなたが持っている問題を示すデモではありません。 HTMLページにはAngular JSファイルは含まれていません。 – Hoa
Emailの一意性をチェックしていますか?指示の方法で行ってください。今は '$ state.reload()'と '$ location.path()'を使って完全なページをリロードしますので、明らかにすべてのデータを失います。 –