آنگولار جی ایس ٹیبل
- پچھلے پیجے پر جائیں آنگولار جی ایس ایچ پی
- پچھلے پیجے پر جائیں آنگولار جی ایس سلیکشن
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>
- پچھلے پیجے پر جائیں آنگولار جی ایس ایچ پی
- پچھلے پیجے پر جائیں آنگولار جی ایس سلیکشن