Angular Ables
AngularJS Tables
The ng-repeat directive is perfect for displaying tables.
Displaying Data inward a Table
Displaying tables amongst angular is rattling simple:AngularJS Example
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr ng-repeat="x inward 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>
Displaying amongst CSS Style
To larn inward nice, add together to a greater extent than or less CSS to the page:CSS Style
<style>
table, th , td {
border: 1px venture grey;
border-collapse: collapse;
padding: 5px;}
table tr:nth-child(odd) {
background-color: #f1f1f1;}
table tr:nth-child(even) {
background-color: #ffffff;}
</style>
Display amongst orderBy Filter
To form the table, add together an orderBy filter:AngularJS Example
<table>
<tr ng-repeat="x inward names | orderBy : 'Country'">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
Display amongst upper-case alphabetic quality Filter
To display uppercase, add together an uppercase filter:AngularJS Example
<table>
<tr ng-repeat="x inward names">
<td>{{ x.Name }}</td>
<td>{{ x.Country | upper-case alphabetic quality }}</td>
</tr>
</table>
Display the Table Index ($index)
To display the tabular array index, add together a <td> amongst $index:AngularJS Example
<table>
<tr ng-repeat="x inward names">
<td>{{ $index + i }}</td>
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
Using $even too $odd
AngularJS Example
<table>
<tr ng-repeat="x inward 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>
Comments
Post a Comment