我有一个 AngularJS 的 UI 问题,现在请记住,我已经使用 Angular.js 2 个小时了,我以前从未使用过它。我继承了一个项目,但我不确定发生了什么……但是
我有以下表单项:
<div><label for="email">email:</label><input type="email" id="email" name="email" required ng-model="user.email" ng-minlength=4></div>
<div><label for="userName">Username:</label><input type="text" name="userName" id="userName" ng-model="user.userName" required ng-pattern="/^[A-Za-z0-9 \-_.]*$/" ng-minlength=4></div>
<div><label for="firstName">Vorname:</label><input type="text" name="firstName" id="firstName" ng-model="user.firstName" required ng-pattern="/^[A-Za-z \-_.]*$/" ng-minlength=3></div>
<div><label for="lastName">Nachname:</label><input type="text" name="lastName" id="lastName" ng-model="user.lastName" required ng-pattern="/^[A-Za-z \-_.]*$/" ng-minlength=4></div>
<div><label for="password1">Passwort:</label><input type="password" name="password1" id="password1" ng-model="user.password1" required ng-minlength=4></div>
<div><label for="password2">Passwort wiederholen:</label><input type="password" name="password2" id="password2" ng-model="user.password2" valid-password2 ng-minlength=4 pw-check="password1"></div>
在我的 CSS 中,我设置了以下 CSS 类
/**
* Form Validation
*/
input.ng-invalid {
border: 1px solid red;
}
input.ng-valid {
border: 1px solid green;
}
但是,当页面第一次加载时,css 规则会应用于空表单项吗?因此,所有的input type="email"
orinput="text"
都应用了红色边框。AngularJS 版本是 v1.0.8
有没有人遇到过这个问题并解决了这个问题?