0
https://github.com/PatrickO10/meetUp/blob/master/index.html#L73
我在這個領域是新的,並閱讀一個代碼。
我看不懂logForm.$invalid.$setValidity
這裏。我無法從互聯網上找到任何有關它的信息。互聯網上的setvalidity
有兩個周長,但這裏沒有。
而且invalid
這裏https://docs.angularjs.org/api/ng/type/form.FormController已被布爾邏輯爲什麼setvalidity
?你爲什麼不使用ng-disabled="logForm.$invalid"
你能告訴我嗎?謝謝。
<div class="modal fade login" tabindex="-1" role="dialog" aria-labelledby="loginModelLabel" ng-controller="LoginCtrl as logCtrl">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header primary-color-dark-bg">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="loginModelLabel">Login</h4>
</div>
<div class="modal-body primary-bg">
<form class="row form-horizontal" id="loginForm" ng-submit="logCtrl.login(user)" name="logForm">
<label for="logEmail" class="col-xs-12 col-md-6 margin-top">
<span class="pad-right">Enter your email</span>
<input type="email" id="logEmail" ng-model="user.email" class="form-control" placeholder="[email protected]" required autocomplete="email" autofocus>
</label>
<label for="logPass" class="col-xs-12 col-md-6 margin-top">
<span>Enter your password</span>
<input type="password" id="logPass" ng-model="user.password" class="form-control" placeholder="Enter your password" required>
</label>
<div class="col-xs-12 margin-top" ng-show="loginError">
<p class="invalidPass">Login Fail! {{loginErrMsg}}</p>
</div>
<label class="col-xs-12 margin-top">
<input id="submitLogin" type="submit" value="Login" ng-disabled="logForm.$invalid.$setValidity">
</label>
</form>
</div>
<div class="modal-footer primary-color-dark-bg">
<button type="submit" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
你能找到一些描述這個setvalidity的文檔嗎? –
看看這個鏈接,它提供了很多$ setValidity的例子。 http://ng-learn.org/2014/03/Writing_Custom_Validations_Part4/ – Thalaivar
而這個鏈接也是... http://blog.thoughtram.io/angularjs/2015/01/11/exploring-angular-1.3-validators- pipeline.html – Thalaivar