㈠ Angularjs 中 ng-if 能不能進行多條件判斷
當然可以,你可以網路一下,有很多的,包括elseif的用法,就不詳細說了。
㈡ angularjs 手機驗證怎麼寫
第一種方法:
<div class="form-group">
<label for="email" class="col-sm-4 control-label">電話:</label>
<div class="col-sm-4">
<input class="form-control" id="tel" placeholder="請輸入電話" type="tel" name="tel"
ng-model="userdata.tel" ng-minlength="11" ng-maxlength="11" ng-pattern="/^1[3|5][0-9]\d{4,8}$/"required>
</div>
<div class="col-sm-4">
<p class="glyphicon glyphicon-ok input_result text-success"
ng-if="signUpForm.tel.$valid"></p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="signUpForm.tel.$error.required&&signUpForm.tel.$touched">電話不能為空!</p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="(signUpForm.tel.$error.minlength||signUpForm.tel.$error.maxlength)&&signUpForm.tel.$touched">請輸入有效手機號!</p> <!--$touched失去焦點再做判斷-->
</div>
</div>
第二種方法:
<div class="form-group">
<label for="email" class="col-sm-4 control-label">電話:</label>
<div class="col-sm-4">
<input class="form-control" id="tel" placeholder="請輸入電話" type="tel" name="tel"
ng-model="userdata.tel" ng-minlength="11" ng-maxlength="11" ng-pattern="/^1[3|5][0-9]\d{4,8}$/"required>
</div>
<div class="col-sm-4">
<p class="glyphicon glyphicon-ok input_result text-success"
ng-if="signUpForm.tel.$valid&&signUpForm.tel.$error.pattern"></p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="signUpForm.tel.$error.required&&signUpForm.tel.$touched">電話不能為空!</p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="(signUpForm.tel.$error.minlength||signUpForm.tel.$error.maxlength)&&signUpForm.tel.$error.pattern&&signUpForm.tel.$touched">請輸入有效手機號!</p>
<!--$touched失去焦點再做判斷-->
</div>
</div>
第三種完全正確:(推薦)
<div class="form-group">
<label for="email" class="col-sm-4 control-label">電話:</label>
<div class="col-sm-4">
<input class="form-control" id="tel" placeholder="請輸入電話" type="tel" name="tel"
ng-model="userdata.tel" ng-minlength="11" ng-maxlength="11" ng-pattern="/^1[3|5][0-9]\d{4,8}$/"required>
</div>
<div class="col-sm-4">
<p class="glyphicon glyphicon-ok input_result text-success"
ng-if="signUpForm.tel.$valid"></p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="signUpForm.tel.$error.required&&signUpForm.tel.$touched">電話不能為空!</p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="(signUpForm.tel.$error.minlength||signUpForm.tel.$error.maxlength||signUpForm.tel.$error.pattern)&&signUpForm.tel.$touched">請輸入有效手機號!</p>
<!--$touched失去焦點再做判斷-->
</div>
</div>