-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo01_2.html
51 lines (46 loc) · 1.21 KB
/
demo01_2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>demo01</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
angular.module("app",[])
.controller("myapp",function($scope,$timeout){
$scope.msg = "hello"
$scope.errormsg = ""
$scope.user = {name:"",psd:""}
$scope.login = function(){
if($scope.user.name == "admin" && $scope.user.psd == "123" ){
alert("登录成功")
}else{
// console.log(123)
$scope.errormsg = "用户名或密码错误"
}
};
var updateClock = function(){
$scope.clock = new Date();
$timeout(function() {
updateClock();
}, 1000);
}
updateClock();
})
</script>
</head>
<body>
<div ng-app="app" ng-controller="myapp">
<input type="text" ng-model="user.name" placeholder="your name">
<h1>{{user.name}}</h1>
<input type="text" ng-model="user.psd">
<div>{{msg}}</div>
<input type="button" ng-click="login()" value="登录">
<div ng-show = "errormsg.length > 0">{{errormsg}}</div>
<div>{{clock}}</div>
</div>
</body>
</html>