Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
  
  <style type="text/css">
    .a-cell {
      background-color: green;
      color: white;
      margin: 0px;
      padding: 0px;
    }
    input.b-cell {
      background-color: blue;
      color: white;
      margin: 0px;
      padding: 0px;
    }
  </style>
</head>
<body>
  <div ng-controller="tableController">
    <table>
      <tr ng-repeat="row in table">
        <td ng-repeat="cell in row">
          <input type="text" ng-model="table[$parent.$index][$index]" class="{{ colorCell( $index) }}">
        </td>
      </tr>
    </table>
  </div>
  <script>
    app = angular.module('app', []);
    app.controller('tableController', function($scope) {
      $scope.table = [
        ["a","b","c","d"],
        ["e","f","g","h"],
        ["i","j","k","l"],
        ["m","n","o","p"]
      ];  
      $scope.colorCell = function( index) {
        
          if (index == 0) {
            return 'a-cell';
          }
          else {
            return "b-cell";
          }
        
      };
    });
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
lucas simonpro
0viewers