AngularJS中实现用户访问的身份认证和表单验证功(3)

<form novalidate ng-app="LoginApp" ng-controller="LoginController" rc-submit="login()"> <div ng-class="{'has-error': rc.loginForm.needsAttention(loginForm.username)}"> <input type="text" placeholder="Username" required ng-model="session.username" /> <span ng-show="rc.form.needsAttention(loginForm.username) &amp;&amp; loginForm.username.$error.required">Required</span> </div> <div ng-class="{'has-error': rc.loginForm.needsAttention(loginForm.password)}"> <input type="password" placeholder="Password" required ng-model="session.password" /> <span ng-show="rc.form.needsAttention(loginForm.password) &amp;&amp; loginForm.password.$error.required">Required</span> </div> <div> <button type="submit" value="Login" title="Login"> <span>Login</span> </button> </div> </form>

样式如下

2016421174922051.png (469×328)

前端验证通过会调用login()。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgywyy.html