查询删除总计

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/angular.min.js"  charset="UTF-8"></script>
</head>
<body ng-app="myapp" ng-controller="mycon">
<input type="text" placeholder="根据名称模糊查询" ng-model="searchKey"/>
<input type="button" value="清空"  ng-click="clearMovie()"/>
<table border="1" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>电影名称</th>
<th>类别</th>
<th>时长</th>
<th>导演</th>
<th>售价</th>
<th>上映时间</th>
<th>评分</th>
<th>操作</th>


</tr>
</thead>
<tbody>
<tr ng-repeat="x in movies|filter:{name:searchKey}">
<td>{{x.name}}</td>
<td>{{x.type}}</td>
<td>{{x.time}}</td>
<td>{{x.author}}</td>
<td>{{x.price}}</td>
<td>{{x.playTime}}</td>
<td>{{x.score}}</td>
<td><input type="button" value="删除" ng-click="deleteG(x.name)"/></td>
</tr>
</tbody>
</table>
<span>总价:{{Totalprice()}}</span>
<script type="text/javascript">
var app=angular.module("myapp",[]);
app.controller("mycon",function($scope){
$scope.movies= [
{"price":35.9,"author":"田羽生","time":120,"type":["喜剧","爱情"],"id":1,"name":"前任三","playTime":1511050949001,"score":9.3},
{"price":45.5,"author":"格雷","time":145,"type":["动作","冒险"],"id":2,"name":"速度与激情8","playTime":1450000949001,"score":9.5}, 
{"price":42.5,"author":"宋阳","time":135,"type":["喜剧","爱情"],"id":3,"name":"羞羞的铁拳","playTime":1511000949001,"score":8.6}, 
{"price":38.9,"author":"弗拉基米尔","time":108,"type":["冒险","科幻"],"id":4,"name":"太空救援","playTime":1516000949001,"score":9.4} ];


$scope.deleteG=function(obj){
for (var i = 0; i < $scope.movies.length; i++) {
if($scope.movies[i].name==obj){
$scope.movies.splice(i,1);
break;
}
}
}
$scope.Totalprice=function(){
var total=0;
for (var i = 0; i < $scope.movies.length; i++) {
total+=$scope.movies[i].price;
}
return total;
}
$scope.clearMovie=function(){
$scope.movies=[];
}
})
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值