ng-if不起作用
<body>
<style>
* { margin: 0; padding: 0;}
.outDiv {
width:500px;
height:500px;
margin:50px auto;
font-family:"华文楷体";
font-size:25px;
}
p {
margin-left:100px;
}
.null {}
.error {
border:1px solid red;
}
.worry {
font-family:"黑体";
font-size:14px;
color:red;
margin-left:100px;
}
input {
width:300px;
height:30px;
margin:10px 0px 10px 100px;
}
.btn {
width:200px;
height:40px;
background-color:#0F0;
border:1px solid #0C0;
margin-left:160px;
}
</style>
<div class="outDiv" ng-controller="myCtrl">
<form name="addForm" ng-submit="upform()">
<h2 align="center">用户注册</h2><br />
<div>
<p>用户名:</p><input type="text" placeholder="请输入用户名" ng-model="username" ng-minlength="4" ng-maxlength="10" required /><br />
<div class="worry" ng-if="addForm.username.$invalid">您输入有误请检查</div>
</div>
<div>
<p>密码:</p><input type="password" placeholder="请输入密码" ng-model="password" />
</div>
<div>
<p>确认密码:</p><input type="password" placeholder="请输入确认密码" ng-model="password2" />
</div>
<div><input type="submit" value="提交" class="btn" /></div>
</form>
</div>
<script src="js/angular-1.3.0/angular.min.js"></script>
<script>
var app = angular.module('myApp',[]);
app.controller('myCtrl',function($scope){
$scope.upform = function(){
console.log('表单提交了!');
};
});
</script>
</body>