<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>try</title>
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="/scripts/jquery.min.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
<style type="text/css">
.wrapper{
width: 200px;
margin:30px auto;
}
</style>
</head>
<body ng-app="" ng-controller="signUpController">
<div class="wrapper">
<form name = "signUpForm" ng-submit="submitForm()">
<h2>sign up register</h2>
<div class="form-group">
<label>userName:</label>
<input type="text"
name="username"
class = "form-control"
ng-model = "userdata.username"
>
<p class = "error"></p>
</div>
<div class="form-group">
<label>password1:</label>
<input type="password"
name="password1"
class = "form-control"
ng-model = "userdata.password1"
>
<p class = "error"></p>
</div>
<div class="form-group">
<label>password2:</label>
<input type="password"
name="password2"
class="form-control"
ng-model = "userdata.password2"
>
</div>
<br>
<div class = "form-froup">
<button type = "submit" class = "btn btn-primary">sign up</button>
</div>
</form>
</div>
<script>
function signUpController($scope){
$scope.userdata = {};
$scope.submitForm = function(){
console.log($scope.userdata);
if($scope.signUpForm.$invalid){
alert("confirm the information!");
}
else {
alert("sign up successed!");
}
}
}
</script>
</body>
</html>
1 回答
已采纳
李晓健
TA贡献1036条经验 获得超461个赞
首先没有看到你引入angular的js文件,其次你写的angular相关的js代码只有angular 1.3以下的版本支持的,1.3以上不是支持这种写法的。具体的可以去看下文档,或者是比较新的教程
添加回答
举报
0/150
提交
取消