-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.html
More file actions
50 lines (49 loc) · 1.17 KB
/
2.html
File metadata and controls
50 lines (49 loc) · 1.17 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script src="../org/angular.js"></script>
</head>
<body>
<div ng-app="hd" ng-controller="ctrl">
{{name}}
<input type=button ng-click='fun()'/>触发函数
<br/>
商品名称:{{goods.title}}<br/>
商品价格:¥{{goods.price}}元<br/>
商品数量:{{goods.num}}个
<input ng-model="goods.num"/>
<button ng-click='add()'>增加</button>
<button ng-click='reduce()'>减少</button>
<br/>
总计价格:¥{{goods.price*goods.num}}元
</div>
<script>
var m=angular.module('hd',[]);
m.controller("ctrl",['$scope',function($scope){
$scope.name="kdfal;dfk;laj";
$scope.fun=function(){
alert(23);
};
$scope.add=function(){
// $scope.goods.num++;
$scope.goods.num=Math.min(++$scope.goods.num,10);
}
$scope.reduce=function(){
// $scope.goods.num++;
$scope.goods.num=Math.max(--$scope.goods.num,0);
}
$scope.goods={
"title":"手机",
"price":2799,
"num":2
};
}]);
</script>
</body>
</html>