我在ng-include中包含了这个模式,该模板也包含在内 -
模态内的表格是:
<div class="input-group form-group">
<span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" ng-model="user.first_name" name="first_name" class="form-control" placeholder="First name" aria-describedby="basic-addon1">
</div>
<div class="input-group form-group">
<span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" ng-model="user.last_name" name="last_name" class="form-control" placeholder="Last name" aria-describedby="basic-addon1">
</div>
<div class="input-group form-group">
<span class="input-group-addon" id="basic-addon1">@</span>
<input type="text" ng-model="user.email" name = "email" class="form-control" placeholder="Email adress" aria-describedby="basic-addon1">
<div ng-show="register_form.$submitted || register_form.email.$touched">
<span ng-show="register_form.email.$error.required">Tell us your email.</span>
<span ng-show="register_form.email.$error.email">This is not a valid email.</span>
</div>
</div>
<div class="input-group form-group">
<span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" ng-model="user.password1" name = "password1" class="form-control" placeholder="Password" aria-describedby="basic-addon1">
</div>
<div class="input-group form-group">
<span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" ng-model="user.password2" name = "password2" class="form-control" placeholder="Confirm password" aria-describedby="basic-addon1">
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="checkbox">
<label>
<input type="checkbox"> Keep me updated
</label>
</div>
</div>
</div>
<small>
By signing up, you agree on the <u> <a href="#" class="modalLink">Terms of use</a></u> and the <u><a href="#" class="modalLink">Privacy policies</a></u> of this site.
</small>
<div class="form-group">
<div class="col-xs-12">
<button type="submit" class="btn btn-default">Sign up</button>
</div>
</div>
<hr>
Already a member? Sign in <u><a data-dismiss="modal" data-toggle="modal" data-target=".login-modal" class="modalLink" href="">here</a></u>
我的控制器:
$scope.registerNew = function(user){
console.log(user);
};
我尝试进行表单验证,但似乎没有任何效果。 你能帮我解决这个问题吗?
答案 0 :(得分:1)
请将<input type="email">
而不是<input type="text">
用于电子邮件字段。使用
<form novalidate>
<input type="email">
</form>
在这种情况下,Angular Js将进行您的电子邮件验证。 “novalidate”是关闭浏览器验证。