码迷,mamicode.com
首页 > Web开发 > 详细

AngularJS 购物车实例

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

标签:angularjs

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 购物车实例

标签:angularjs

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!