AngularJS $even과 $odd 사용하기

· 8년 전 · 1121
AngularJS $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>


<!DOCTYPE html>
<html>
<style>
table, td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="customersCtrl">

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

</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>

</body>
</html>
|
댓글을 작성하시려면 로그인이 필요합니다.

퍼블리싱강좌

+
분류 제목 글쓴이 날짜 조회
AngularJS
[AngularJS]
8년 전 조회 1,155
AngularJS
[AngularJS]
8년 전 조회 1,505
AngularJS 8년 전 조회 1,420
AngularJS 8년 전 조회 1,387
AngularJS 8년 전 조회 1,552
AngularJS 8년 전 조회 1,341
AngularJS 8년 전 조회 1,395
AngularJS 8년 전 조회 1,506
AngularJS 8년 전 조회 1,262
AngularJS 8년 전 조회 2,000
AngularJS 8년 전 조회 1,571
AngularJS 8년 전 조회 1,223
AngularJS 8년 전 조회 1,534
AngularJS 8년 전 조회 1,310
AngularJS 8년 전 조회 1,122
AngularJS 8년 전 조회 2,092
AngularJS 8년 전 조회 1,170
AngularJS 8년 전 조회 1,231
AngularJS 8년 전 조회 1,426
AngularJS 8년 전 조회 1,275
AngularJS 8년 전 조회 1,466
AngularJS 8년 전 조회 1,482
AngularJS 8년 전 조회 1,252
AngularJS 8년 전 조회 1,218
AngularJS 8년 전 조회 1,619
AngularJS 8년 전 조회 1,606
AngularJS 8년 전 조회 1,447
AngularJS 8년 전 조회 1,321
AngularJS 8년 전 조회 1,758
AngularJS 8년 전 조회 1,209