以下是添加的内容:
//添加
$scope.add=function(){
//清除验证文本
$(".tip").text("");
//数据隐藏
$scope.addShow=false;
//验证
var tid=$("#tid").val();
var tname=$("#tname").val();
var tnum=$("#tnum").val();
var tprice=$("#tprice").val();
//验证
if(tname=="" || tname==null || tname==undefined){
$("#tname_text").text("*电影名称不能为空");
return;
}
var newshops={};
newshops.gid=tid;
newshops.gname=tname;
newshops.gnum=tnum;
newshops.gprice=tprice;
$scope.shops.push(newshops);
}
下面是修改的内容:
var data=[];
//回显
$scope.change=function(id){
$scope.changeshow=true;
for (var i = 0; i <$scope.moives.length; i++) {
if($scope.moives[i].id==id){
data=$scope.moives[i];
$scope.xprice=$scope.moives[i].price;
}
}
}
//修改
$scope.update=function(){
$scope.changeshow=false;
data.price=$scope.xprice;
}
//弹框修改
//回显
var modifydata;
$scope.modify=function(id){
for(var i = 0; i < $scope.films.length; i++) {
if($scope.films[i].id == id) {
modifydata=$scope.films[i];
break;
}
}
//弹出提示框
var data=prompt("请输入要修改的票价:",modifydata.price);
if(data!=null){
modifydata.price=data;
}
}
数量加减+ -
<input type="button" value="-" ng-click="reduceNum($index)" />
//减少数量
$scope.reduceNum=function($index){
$scope.goods[$index].num--;
//判断小于1删除
if($scope.goods[$index].num<=0){
$scope.goods[$index].num=0;
}
}
//增加数量
$scope.addNum=function($index){
$scope.goods[$index].num++;
}