angularJS学习1

<!DOCTYPE html>
<html ng-app>
<head>

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
</head>
<body ng-controller='CartController'>
<table>
<tr ng-repeat='item in items'>

<td><span>{{item.title}}</span></td>
<td><input ng-model='item.quantity' /></td>
<td><span ng-bind="item.price"></span><span>元</span></td>
<td><span>{{item.price*item.quantity}}元</span></td>
<td><button ng-click='remove($index)'>Remove</button></td>

</tr>
</table>
<script>
function CartController($scope)
{
$scope.items=[
{
title:'book1',
quantity:1,
price:68.5
},
{
title:'book2',
quantity:1,
price:78.5
}
];
$scope.remove=function(index)
{
$scope.items.splice(index,1);
}
}
</script>
</body>
</html>

posted @ 2015-11-30 15:11  zslm___  阅读(135)  评论(0编辑  收藏  举报