0
我無法在一些有多個驗證的字段中清除我的表單。任何人都可以幫忙嗎?在AngularJs中按下取消按鈕後無法清除整個表單?
<div class="col-lg-4 col-md-6">
<div class="form-group" data-ng-class="{ 'has-error' : vm.form.phonenumber.$invalid && (vm.form.phonenumber.$dirty || vm.form.phonenumber.$touched)}">
<label class="control-label col-md-4 col-sm-3 col-xs-12" data-i18n=" _phoneNumber_"></label>
<div class="col-md-8 col-sm-8 col-xs-10">
<input type="text" class="form-control col-md-7 col-xs-12" data-ng-model="vm.person.phoneNumber" required name="phonenumber" ng-pattern="/^[0-9]{10}$/" />
<span data-ng-show="vm.form.phonenumber.$error.required && (vm.form.phonenumber.$dirty || vm.form.phonenumber.$touched)" class="help-block" data-i18n="_phoneNumrequired_"></span>
<span class="help-block" data-ng-show="vm.form.phonenumber.$error.pattern && vm.form.phonenumber.$dirty" data-i18n="_phoneNuminvalid_"></span>
</div>
</div>
</div>
<div class="col-lg-4 col-md-6">
<div class="form-group" data-ng-class="{ 'has-error' : vm.form.mobilenumber.$invalid && (vm.form.mobilenumber.$dirty || vm.form.mobilenumber.$touched)}">
<label class="control-label col-md-4 col-sm-3 col-xs-12" data-i18n=" _mobileNumber_"></label>
<div class="col-md-8 col-sm-8 col-xs-10">
<input type="text" class="form-control col-md-7 col-xs-12" data-ng-model="vm.person.mobileNumber" required name="mobilenumber" ng-pattern="/^[0-9]{10}$/" />
<span data-ng-show="vm.form.mobilenumber.$error.required && (vm.form.mobilenumber.$dirty || vm.form.mobilenumber.$touched)" class="help-block" data-i18n="_mobileNumrequired_"></span>
<span class="help-block" data-ng-show="vm.form.mobilenumber.$error.pattern && vm.form.mobilenumber.$dirty" data-i18n="_mobileNuminvalid_"></span>
</div>
</div>
</div>`
角函數:
function cancel() { vm.person = angular.copy(vm.original); vm.form.$setPristine(); vm.form.$setUntouched(); }
this is before pressing cancel
你可以看到在電子郵件中的數據,手機和手機不被清除
是啊,這對我來說工作壓力太大,但其驗證不,當你輸入無效數據。無論如何感謝您的幫助 – Raja