dwf

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="angular.min.js" ></script>
<script type="text/javascript" src="jquery-1.8.3.js" ></script>
<script>
var app=angular.module("myapp",[]);
app.controller("myctrl",function($scope,$http){
$scope.moves=[
{"name":"前任三","price":"70","product":"北京"},
{"name":"山楂树","price":"60","product":"河北"},
{"name":"西游记","price":"50","product":"天津"},
{"name":"葫芦娃","price":"45","product":"上海"},
];
$scope.orderKey="";
$scope.seacherKey="";
$scope.showTable=true;
$scope.checkAll=false;
$scope.showUpdate=false;
$scope.showAdd=false;
//添加
$scope.add1 = function (){
$scope.showAdd=true;
}
$scope.addMoves=function(){
var move={};
move.name=$scope.name;
move.price=$scope.price;
move.product=$scope.product;
$scope.moves.push(move);
$scope.showAdd=false;
$scope.showTable=true;
}
//删除按钮事件
$scope.delete=function($index){
$scope.moves.splice($index,1);
if ($scope.moves.length==0) {
$scope.showTable=false;
}
}
//批量删除
$scope.deleteMOre=function(){
$(":checkbox:checked").each(function(){
var id1=$(this).val();
alert(id1);
for (var i=0;i<$scope.moves.length;i++) {
if($scope.moves[i].name == id1){
$scope.moves.splice(i,1);
}

}
})

}
//定义回显接收的字段
$scope.upname="";
$scope.upprice="";
$scope.upproduct="";
//修改的回显数据
$scope.showMoves=function($index){
$scope.showUpdate=true;
var move=$scope.moves[$index];
$scope.upname=move.name;
$scope.upprice=move.price;
$scope.upproduct=move.product;
//记录修改的索引
$scope.upindex=$index;
}
//修改数据给修改按钮一个事件
$scope.Update=function(){
$scope.moves[$scope.upindex].name=$scope.upname;
$scope.moves[$scope.upindex].price=$scope.upprice;
$scope.moves[$scope.upindex].product=$scope.upproduct;
   $scope.showUpdate=false;
}
})
</script>
</head>
<body ng-app="myapp" ng-controller="myctrl">
<center>
<input type="text" placeholder="输入电影名称" ng-model="seacherKey" />
排序:<select ng-model="orderKey">
<option value="">--请选择--</option>
<option value="name">--名称正序--</option>
<option value="-name">--名称倒序--</option>
<option value="price">--价格正序--</option>
<option value="-price">--价格倒序--</option>
</select>
<input type="button" value="添加" ng-click="add1()" />
<br />
<div ng-show="showAdd">
电影名称:<input type="text" placeholder="请输入电影名称" ng-model="name" /><br />
电影售价:<input type="text" placeholder="请输入电影售价" ng-model="price" /><br />
地址:<input type="text" placeholder="请输入电影地址" ng-model="product" /><br />
<input type="button" value="添加" ng-click="addMoves();" />
</div>
<table border="1px" ng-show="showTable">
<tr>
<th> <input type="checkbox" ng-model="checkAll" /> </th>
<th>电影名称</th>
<th>售价</th>
<th>地点</th>
<th>操作</th>
</tr>
<tr ng-repeat="m in moves | orderBy:orderKey | filter:seacherKey">
<td> <input type="checkbox" ng-model="checkAll" value="{{m.name}}" /> </td>
<td>{{m.name}}</td>
<td>{{m.price | currency:"¥: "}}</td>
<td>{{m.product}}</td>
<td> <input type="button" value="删除" ng-click="delete($index);" /> 
<input type="button" value="修改" ng-click="showMoves($index);" />
</td>
</tr>
</table>
<input type="button" value="批量删除" ng-click="deleteMOre();" />
<div ng-show="showUpdate">
电影名称:<input type="text" ng-model="upname" /><br />
电影售价:<input type="text" ng-model="upprice" /><br />
地址:<input type="text" ng-model="upproduct" /><br />
<input type="button" value="修改" ng-click="Update();" />
</div>
</center>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值