<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/angular.js" ></script>
<style>
.redColor{ color:red; }
</style>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$scope.goods=[{"id":80,"name":"iphone","price":5400},
{"id":1200,"name":"ipad mini","price":2200},
{"id":500,"name":"ipad air","price":2340},
{"id":29,"name":"ipad","price":1420},
{"id":910,"name":"imac","price":15400}];
$scope.orderColumn="name";
$scope.orderSign="-";
$scope.sortProduct=function(sortColumn){
$scope.orderColumn=sortColumn;
if($scope.orderSign=="-"){
$scope.orderSign="";
}else{
$scope.orderSign="-";
}
}
$scope.remove = function(name) {
if(confirm("確定要清空"+name+"嗎")) {
var p;
for(index in $scope.goods ){
p=$scope.goods[index];
if(p.name==name){
$scope.goods.splice(index,1);
}
}
}
}
$scope.removeAll = function() {
if(confirm("你確定套清空購(gòu)物車所有商品嗎?")) {
$scope.goods = [];
}
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<input type="text" ng-model="search" placeholder="產(chǎn)品名稱"/>
<button ng-click="removeAll()">全部刪除</button>
<table border="1"cellspacing="0">
<tr>
<td>產(chǎn)品編號(hào)<button ng-click="sortProduct('id')">^</button></td>
<td>產(chǎn)品名稱<button ng-click="sortProduct('name')">^</button></td>
<td>產(chǎn)品價(jià)格<button ng-click="sortProduct('price')">^</button></td>
<td><a>刪除</a></td>
</tr>
<tr ng-repeat="x in goods | filter:{'name':search}|orderBy:(orderSign + orderColumn)">
<td>{{x.id }}</td>
<td>{{x.name}}</td>
<td>{{x.price |currency :"(RMB)"}}</td>
<td ng-click="remove(x.name)"><a>刪除</a></td>
</tr>
</table>
</body>
</html>
An_form排序
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
推薦閱讀更多精彩內(nèi)容
- This chapter covers Effects with jQuery jQuery's utility ...
- “上一輩創(chuàng)業(yè)者必須有資金才能夠開(kāi)始創(chuàng)業(yè),但今天的創(chuàng)業(yè)者只要能夠抓住一個(gè)創(chuàng)業(yè)亮點(diǎn),就可以獲得全世界的投資。” ...
- 原以為可以順利離職,不曾想中間發(fā)生了一點(diǎn)小波瀾,那一刻,我的內(nèi)心是崩潰的。 按照公司正常手續(xù),我應(yīng)該提前一個(gè)月辭職...