ఏంజులర్ జి టేబుల్

ng-repeat ఆదేశం పట్టికలను ప్రదర్శించడానికి చక్కగా ఉపయోగపడుతుంది.

పట్టికలో డాటాను ప్రదర్శించండి

పట్టికను ప్రదర్శించడం అంగుళంగా ఉంది ఉంటుంది:

ఏంజులర్ జి ఎక్సామ్ప్లే

<div ng-app="myApp" ng-controller="customersCtrl">
<table>
  <tr ng-repeat="x in names">
    <td>{{ x.Name }}</td>
    <td>{{ x.Country }}</td>
  </tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
  $http.get("customers.php")
  .then(function (response) {$scope.names = response.data.records;});
});
</script>

స్వయంగా ప్రయత్నించండి

CSS శైలు ఉపయోగించడం ద్వారా ప్రదర్శించండి

దానిని అందంగా చూడడానికి పేజీకి CSS చేర్చండి అని చెప్పవచ్చు:

CSS శైలు

<style>
table, th , td {
  border: 1px solid grey;
  border-collapse: collapse;
  padding: 5px;
}
table tr:nth-child(odd) {
  background-color: #f1f1f1;
}
table tr:nth-child(even) {
  background-color: #ffffff;
}
</style>

స్వయంగా ప్రయత్నించండి

orderBy ఫిల్టర్ కార్యకలాపం ఉపయోగించడం ద్వారా ప్రదర్శించండి

పట్టికను క్రమబద్ధం చేయడానికి కలిపి ఉంచండి orderBy ఫిల్టర్ కార్యకలాపం:

ఏంజులర్ జి ఎక్సామ్ప్లే

<table>
  <tr ng-repeat="x in names | orderBy : 'Country'">
    <td>{{ x.Name }}</td>
    <td>{{ x.Country }}</td>
  </tr>
</table>

స్వయంగా ప్రయత్నించండి

uppercase ఫిల్టర్ కార్యకలాపం ఉపయోగించడం ద్వారా ప్రదర్శించండి

పెద్ద అక్షరాలలో ప్రదర్శించడానికి కలిపి ఉంచండి uppercase ఫిల్టర్ కార్యకలాపం:

ఏంజులర్ జి ఎక్సామ్ప్లే

<table>
  <tr ng-repeat="x in names">
    <td>{{ x.Name }}</td>
    <td>{{ x.Country | uppercase }}</td>
  </tr>
</table>

స్వయంగా ప్రయత్నించండి

పట్టిక సంఖ్యను ప్రదర్శించండి ($index)

పట్టిక సంఖ్యను ప్రదర్శించడానికి కలిపి ఉంచండి $index యొక్క <td>:

ఏంజులర్ జి ఎక్సామ్ప్లే

<table>
  <tr ng-repeat="x in names">
    <td>{{ $index + 1 }}</td>
    <td>{{ x.Name }}</td>
    <td>{{ x.Country }}</td>
  </tr>
</table>

స్వయంగా ప్రయత్నించండి

ఉపయోగించండి $even మరియు $odd

ఏంజులర్ జి ఎక్సామ్ప్లే

<table>
  <tr ng-repeat="x in names">
    <td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Name }}</td>
    <td ng-if="$even">{{ x.Name }}</td>
    <td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Country }}</td>
    <td ng-if="$even">{{ x.Country }}</td>
  </tr>
</table>

స్వయంగా ప్రయత్నించండి