首页 > 其他 > 详细

Angular 学习笔记——shop

时间:2015-11-23 13:28:54      阅读:224      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript" src="js/angular-1.3.0.js"></script>
	<script>
		function shop($scope){
			$scope.items = {
				"name":"apple",
				"price":"5",
				"quantity":"5",
				"fre":"10"	
			};

			$scope.sum = function (){
				return $scope.items.price * $scope.items.quantity;
			};

			$scope.$watch($scope.sum,function(newVal,oldVal){

				$scope.items.fre = newVal >= 100 ? 0 : 10;
			});
		}
	</script>
</head>
<body ng-controller="shop">
	<div >
		<span>{{items.name}}</span><br/>
		<span>{{items.price}}</span><br/>
		<input  type="text" ng-model="items.quantity"><br/>
		<span>{{items.fre  | currency:‘¥‘ }}</span><br/>
		<span>{{sum() + items.fre | currency:‘¥‘}}</span>
	</div>
</body>
</html>

 

Angular 学习笔记——shop

原文:http://www.cnblogs.com/mayufo/p/4988023.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!