我有一個婚禮RSVP形式角度驗證渲染NG-有效形式時是無效
我試圖隱藏的DONE提交按鈕,只顯示它時,形式是有效的。
<form method="POST" action="http://l.bheng.com:8888/wedding" accept-charset="UTF-8" class="ng-pristine ng-pristine ng-valid ng-valid-required ng-valid-email" role="form" id="rsvp-form" name="rsvp-form">
<input name="_token" type="hidden" value="JK8PC04aF7xGsbcQoTvzz2FV61od1DmGdraiZNwB">
<div class="col-xs-12 form-group">
<label for="">Are you attending ? </label>
<br>
<label for="going">
<input type="radio" id="going" value="1" ng-model="going" class="ng-pristine ng-untouched ng-valid ng-not-empty" name="3"> Yes
</label>
<label for="going">
<input type="radio" id="going" value="0" ng-model="going" class="ng-pristine ng-untouched ng-valid ng-not-empty" name="4"> No
</label>
</div>
<div class="col-xs-12 form-group">
<label for="">Number of total guests ? </label>
<br>
<select id="guestNum">
<option value="1">Just Me</option>
<option value="2">Me and My +1</option>
</select>
</div>
<div class="col-xs-12 form-group">
<label for="">Name</label>
<input type="text" class="normal ng-pristine ng-untouched ng-valid ng-empty ng-valid-required" id="name" placeholder="Name" ng-model="name" ng-required="required">
</div>
<div class="col-xs-12 form-group">
<label for="">Email</label>
<input type="email" class="normal ng-pristine ng-untouched ng-valid ng-empty ng-valid-email ng-valid-required" placeholder="Email Address" id="email" ng-required="required" ng-model="email">
</div>
<div class="col-xs-12 form-group">
<label for="">Message</label>
<textarea id="message" ng-model="message" rows="5" type="text" class="normal ng-pristine ng-untouched ng-valid ng-empty" placeholder="Message to us "></textarea>
<grammarly-btn>
<div data-reactroot="" class="_e725ae-textarea_btn _e725ae-anonymous _e725ae-not_focused" style="visibility: hidden; z-index: 2;">
<div class="_e725ae-transform_wrap">
<div title="Protected by Grammarly" class="_e725ae-status"> </div>
</div>
</div>
</grammarly-btn>
</div>
<div class="col-xs-12" ng-hide="rsvp-form.name.$invalid || rsvp-form.email.$invalid ">
<a id="rsvp-submit" ng-click="rsvp()" class="button" style="width: 100%;">
Done
<img src="/img/svg/default.svg" alt="Loading" style="width: 30px; float: right; padding-top: 7px; " class="hidden loading">
</a>
</div>
</form>
我的完成按鈕會一直顯示,不管是什麼。
我該如何阻止?
我的表單如何擁有這個類?
ng-pristine
ng-valid
< ---這怎麼可能?我什至不輸入任何名稱/電子郵件ng-valid-required
< ---這怎麼可能?我什至不輸入任何名稱/電子郵件ng-valid-email
< ---這怎麼可能?我沒有名字/甚至輸入任何電子郵件
的jsfiddle = https://jsfiddle.net/bheng/Ln3tqzcu/
你能提供一個工作小提琴嗎?我的建議是你的''''ng-hide''正在錯誤的位置尋找數據來驗證,因爲你的'name'模型例如存儲在作爲'''name''的作用域中,並且不在對象'''rsvp-form'''中,但小提琴可以幫助調試;) –
你是否在原始文件中包含了'ng-pristine ng-pristine ng-valid ng-valid-required ng-valid-email' HTML? –
@AlonEitan:不,我沒有包括這一點。當我刷新頁面時它會自動生成。我在「查看頁面源代碼」之後複製它。 – ihue