<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../css/index3.css"/>
<script src="../js/angular.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var app=angular.module("myapp",[]);
app.controller("myctrl",function ($scope,$http) {
$scope.order=["--按要求排序--","按电影时长排序","按售价排序","按上映时间排序","按评分排序"];
$http.get("action.json").then(function (success) {
$scope.action=success.data;
alert($scope.action.length);
})
//删除
$scope.del=function (index) {
if(confirm("您确定要删除吗?")){
$scope.action.splice(index,1);
}
}
//全选 全不选
$scope.ck=function () {
for (var i = 0; i < $scope.action.length; i++) {
$scope.action[i].checked=$scope.ischeck;
}
}
//批量删除
$scope.delAll=function () {
for (var i = 0; i < $scope.action.length; i++) {
if($scope.action[i].checked==true){
$scope.action.splice(i,1);
i--;
}
}
}
//排序
$scope.change=function () {
var value=$scope.selectValue;
switch (value){
case "按电影时长排序":
$scope.action.sort(function (a,b) {
return a.time-b.time;
})
break;
case "按电影时长排序":
$scope.action.sort(function (a,b) {
return b.time-a.time;
})
break;
case "按售价排序":
$scope.action.sort(function (a,b) {
return a.price-b.price;
})
break;
case "按售价排序":
$scope.action.sort(function (a,b) {
return b.price-a.price;
})
break;
case "按上映时间排序":
$scope.action.sort(function (a,b) {
return b.playTime-a.playTime;
})
break;
case "按评分排序":
$scope.action.sort(function (a,b) {
return b.score-a.score;
})
break;
default:
break;
}
}
$scope.update=function (index) {
/*$scope.action[index].score=prompt("修改评分").innerText==index;
*/
var a=prompt("请修改评分",$scope.action[index].score);
if(a==null||a==""){
alert("请输入修改内容");
}else{
$scope.action[index].score=a;
}
}
})
</script>
</head>
<body ng-app="myapp" ng-controller="myctrl">
<input type="text" placeholder="按电影名称模糊查询..." ng-model="select_name" />
<select ng-model="selectValue" ng-options="s for s in order" ng-init="selectValue=order[0]" ng-change="change()">
{{s}}
</select>
<button ng-click="delAll()">批量删除</button>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
<input type="checkbox" ng-model="ischeck" ng-click="ck()"/>
</td>
<td>电影名称</td>
<td>类别</td>
<td>时长</td>
<td>导演</td>
<td>售价</td>
<td>上映时间</td>
<td>评分</td>
<td>操作</td>
</tr>
<tr ng-repeat="s in action|filter:{'name':select_name}">
<td>
<input type="checkbox" ng-model="s.checked" />
</td>
<td>{{s.name}}</td>
<td>{{s.type}}</td>
<td>{{s.time}}</td>
<td>{{s.author}}</td>
<td>{{s.price|currency:"¥"}}</td>
<td>{{s.playTime|date:"yyyy-MM-dd hh:mm:ss"}}</td>
<td>{{s.score}}</td>
<td>
<button ng-click="update($index)" >修改</button>
<button ng-click="del($index)">删除</button>
</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../css/index3.css"/>
<script src="../js/angular.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var app=angular.module("myapp",[]);
app.controller("myctrl",function ($scope,$http) {
$scope.order=["--按要求排序--","按电影时长排序","按售价排序","按上映时间排序","按评分排序"];
$http.get("action.json").then(function (success) {
$scope.action=success.data;
alert($scope.action.length);
})
//删除
$scope.del=function (index) {
if(confirm("您确定要删除吗?")){
$scope.action.splice(index,1);
}
}
//全选 全不选
$scope.ck=function () {
for (var i = 0; i < $scope.action.length; i++) {
$scope.action[i].checked=$scope.ischeck;
}
}
//批量删除
$scope.delAll=function () {
for (var i = 0; i < $scope.action.length; i++) {
if($scope.action[i].checked==true){
$scope.action.splice(i,1);
i--;
}
}
}
//排序
$scope.change=function () {
var value=$scope.selectValue;
switch (value){
case "按电影时长排序":
$scope.action.sort(function (a,b) {
return a.time-b.time;
})
break;
case "按电影时长排序":
$scope.action.sort(function (a,b) {
return b.time-a.time;
})
break;
case "按售价排序":
$scope.action.sort(function (a,b) {
return a.price-b.price;
})
break;
case "按售价排序":
$scope.action.sort(function (a,b) {
return b.price-a.price;
})
break;
case "按上映时间排序":
$scope.action.sort(function (a,b) {
return b.playTime-a.playTime;
})
break;
case "按评分排序":
$scope.action.sort(function (a,b) {
return b.score-a.score;
})
break;
default:
break;
}
}
$scope.update=function (index) {
/*$scope.action[index].score=prompt("修改评分").innerText==index;
*/
var a=prompt("请修改评分",$scope.action[index].score);
if(a==null||a==""){
alert("请输入修改内容");
}else{
$scope.action[index].score=a;
}
}
})
</script>
</head>
<body ng-app="myapp" ng-controller="myctrl">
<input type="text" placeholder="按电影名称模糊查询..." ng-model="select_name" />
<select ng-model="selectValue" ng-options="s for s in order" ng-init="selectValue=order[0]" ng-change="change()">
{{s}}
</select>
<button ng-click="delAll()">批量删除</button>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
<input type="checkbox" ng-model="ischeck" ng-click="ck()"/>
</td>
<td>电影名称</td>
<td>类别</td>
<td>时长</td>
<td>导演</td>
<td>售价</td>
<td>上映时间</td>
<td>评分</td>
<td>操作</td>
</tr>
<tr ng-repeat="s in action|filter:{'name':select_name}">
<td>
<input type="checkbox" ng-model="s.checked" />
</td>
<td>{{s.name}}</td>
<td>{{s.type}}</td>
<td>{{s.time}}</td>
<td>{{s.author}}</td>
<td>{{s.price|currency:"¥"}}</td>
<td>{{s.playTime|date:"yyyy-MM-dd hh:mm:ss"}}</td>
<td>{{s.score}}</td>
<td>
<button ng-click="update($index)" >修改</button>
<button ng-click="del($index)">删除</button>
</td>
</tr>
</table>
</body>
</html>