<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
app.controller("ctrlDemo1",function($scope){
$scope.goods=[{gname:"云南白药",gnum:100,address:"云南",price:19.9,regdate:new Date("2017-11-20 09:21:20")},
{gname:"999感冒",gnum:30,address:"北京",price:20.1,regdate:new Date("2018-1-21")},
{gname:"感康",gnum:30,address:"河北",price:22,regdate:new Date("2017-11-21")}]
})
</script>
<style>
table{
width: 600px;
}
</style>
</head>
<body>
<body ng-app="myApp" ng-controller="ctrlDemo1">
<input ng-model="selname" placeholder="请输入查询的商品名" />
<select ng-model="px">
<option value="">--请选择---</option>
<option value="price">按照价格升序</option>
<option value="-price">按照价格降序</option>
<option value="regdate">按照生产日期升序</option>
<option value="-regdate">按照生产日期降序</option>
</select>
<table border="1px" >
<tr>
<td>索引</td>
<td>商品名称</td>
<td>数量</td>
<td>地址</td>
<td>价格</td>
<td>出厂日期</td>
</tr>
<tr ng-repeat="g in goods|filter:{gname:selname}|orderBy:px">
<td>{{$index}}</td>
<td>{{g.gname}}</td>
<td>{{g.gnum}}</td>
<td>{{g.address}}</td>
<td>{{g.price|currency:"¥:"}}</td>
<td>{{g.regdate|date:"yyyy-MM-dd hh:mm:ss"}}</td>
</tr>
</table>
</body>
</html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
app.controller("ctrlDemo1",function($scope){
$scope.goods=[{gname:"云南白药",gnum:100,address:"云南",price:19.9,regdate:new Date("2017-11-20 09:21:20")},
{gname:"999感冒",gnum:30,address:"北京",price:20.1,regdate:new Date("2018-1-21")},
{gname:"感康",gnum:30,address:"河北",price:22,regdate:new Date("2017-11-21")}]
})
</script>
<style>
table{
width: 600px;
}
</style>
</head>
<body>
<body ng-app="myApp" ng-controller="ctrlDemo1">
<input ng-model="selname" placeholder="请输入查询的商品名" />
<select ng-model="px">
<option value="">--请选择---</option>
<option value="price">按照价格升序</option>
<option value="-price">按照价格降序</option>
<option value="regdate">按照生产日期升序</option>
<option value="-regdate">按照生产日期降序</option>
</select>
<table border="1px" >
<tr>
<td>索引</td>
<td>商品名称</td>
<td>数量</td>
<td>地址</td>
<td>价格</td>
<td>出厂日期</td>
</tr>
<tr ng-repeat="g in goods|filter:{gname:selname}|orderBy:px">
<td>{{$index}}</td>
<td>{{g.gname}}</td>
<td>{{g.gnum}}</td>
<td>{{g.address}}</td>
<td>{{g.price|currency:"¥:"}}</td>
<td>{{g.regdate|date:"yyyy-MM-dd hh:mm:ss"}}</td>
</tr>
</table>
</body>
</html>