Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
Hello, {{name}}!
<!--
<div ng-repeat="item in realName" ng-style='{"background-color":((item.id)%2==0?"white":"#F0F0F0 ")}' style="cursor:pointer" >-->
<div ng-repeat="item in realName" ng-style="set_color(item.id)" style="cursor:pointer" >
{{item.id}}
{{item.name}}
</div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.name = 'Superhero';
$scope.realName=[{"id":1,"name":"A"},{"id":2,"name":"B"},{"id":3,"name":"c"},{"id":4,"name":"D"},{"id":5,"name":"E"},{"id":6,"name":"F"}];
$scope.set_color = function(id) {
//{"background-color":((item.id)%2==0?"white":"#F0F0F0 ")}
if(id%2 == 0)
return {"background-color": "white"};
else
return {"background-color": "#F0F0F0"};
};
}