「AngularJS」ng-class-oddで奇数行に対しスタイルを設定するサンプル
構文
<element ng-class-odd="expression"></element>
使用例
htmlコード
<head> <meta charset="utf-8"> <script src="/angular.js/1.4.6/angular.min.js"></script> <style> .cft { color:white; background-color:red; } </style> </head>
JSコード
<body ng-app="arkgame"> <table ng-controller="ttCtrl"> <tr ng-repeat="x in records" ng-class-odd="'cft'"> <td>{{x.Name}}</td> <td>{{x.Country}}</td> </tr> </table> <script> var app = angular.module("arkgame", []); app.controller("ttCtrl", function($scope) { $scope.records = [ { "Name" : "A111", "Country" : "Germany" }, { "Name" : "B222", "Country" : "Sweden" }, { "Name" : "C333", "Country" : "Mexico" }, { "Name" : "E444", "Country" : "Austria" } ] }); </script>