03-03-OrderColumn.html
Dosyayı İndir
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8"/>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script>
angular.module('myApp', []).controller('myCtrl', function($scope) {
$scope.products = [
{productId:301,productName:'Cep Telefonu',salesPrice:1200},
{productId:302,productName:'Masaüstü Bilgisayar',salesPrice:3250},
{productId:303,productName:'Diziüstü Bilgisayar',salesPrice:2100}
];
$scope.orderFunction = function(columnName) {
$scope.orderColumn = columnName;
}
});
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<table border="1" width="100%">
<tr>
<th ng-click="orderFunction('productId')">ÜRÜN KİM</th>
<th ng-click="orderFunction('productName')">ÜRÜN ADI</th>
<th ng-click="orderFunction('salesPrice')">SATIŞ FİYATI</th>
</tr>
<tr ng-repeat="product in products|orderBy:orderColumn">
<td>{{product.productId}}</td>
<td>{{product.productName}}</td>
<td>{{product.salesPrice}}</td>
</tr>
</table>
</div>
</body>
</html>
Dosyayı İndir