آنگولار جی ایس ٹیبل

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 ਸਟਾਈਲ

<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 ਦਾ <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>

خود کا تجربہ کریں