首页 > Web开发 > 详细

AngularJS 购物车实例

时间:2015-02-27 11:53:54      阅读:331      评论:0      收藏:0      [点我收藏+]

html 页面

<!DOCTYPE html>
<html ng-app>
<head>
	<title>Angular.js</title>
	<script type="text/javascript" src="angular-1.3.0.js"> </script>
	<script type="text/javascript" src="test.js"></script>
</head>
<body ng-controller="CartController">

<div ng-repeat="item in items">
<h3>your order</h3>
<span>{{item.title}}</span>
<input type="text" ng-model="item.quantity">
<span>{{item.price | currency}}</span>
<span>{{item.price * item.quantity | currency}}</span>
<button ng-click="remove($index)">remove</button>
</div>
</body>
</html>


 

js页面

function CartController($scope){
	$scope.items = [
		{title:"paint posts", quantity:"8", price:"7.8"},
		{title:"paint posts", quantity:"8", price:"7.8"},
		{title:"paint posts", quantity:"8", price:"7.8"}
	];

	$scope.remove = function(index){
		$scope.items.splice(index,1);
	}
}	

AngularJS 购物车实例

原文:http://blog.csdn.net/u012079603/article/details/43965843

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