angular的修改注重回显

<!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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值