<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title></title> | |
<script src="js/angular.js"></script> | |
<script> | |
var app=angular.module("myapp",[]) | |
app.controller("myctrl",function($scope){ | |
$scope.arr=[ | |
{"bianhao":8,"name":"iphone1","price":6767}, | |
{"bianhao":5,"name":"iphone2","price":6733}, | |
{"bianhao":34,"name":"iphone3","price":6757}, | |
{"bianhao":2,"name":"iphone4","price":65567}, | |
{"bianhao":56,"name":"iphone5","price":6367}, | |
] | |
$scope.del=function(newname){ | |
if(newname!="") | |
{ for(index in $scope.arr) | |
{ | |
var na=$scope.arr[index].name | |
if(na==newname) | |
{ | |
$scope.arr.splice(index,1) | |
} | |
} | |
} | |
} | |
$scope.delall=function($index){ | |
$scope.arr.splice($index) | |
} | |
$scope.col="name" | |
$scope.desc=0 | |
}) | |
</script> | |
<style> | |
tr{ text-align: center;} | |
</style> | |
</head> | |
<body ng-app="myapp" ng-controller="myctrl"> | |
<center> | |
<input type="text" placeholder="产品名称" id="select" ng-model="selt"/> | |
<font ng-click="delall($index)">全部删除</font> | |
<table cellpadding="0" border="1px" cellspacing="0" width="600"> | |
<tr> | |
<th ng-click="col='bianhao';desc=!desc">产品编号</th> | |
<th ng-click="col='name';desc=!desc">产品名称</th> | |
<th ng-click="col='price';desc=!desc">产品价格</th> | |
<th><font>操作</font></th> | |
</tr> | |
<tr ng-repeat="a in arr|orderBy:col:desc|filter:selt"> | |
<td>{{a.bianhao}}</td> | |
<td>{{a.name}}</td> | |
<td>{{a.price|currency:"(RMB)"}}</td> | |
<td><font ng-click="del(a.name)">删除</font></td> | |
</tr> | |
</table> | |
</center> | |
</body> | |
</html> | |