AngularJS Example:

by stevenkaspar

HTML

<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app>
  <div ng-controller="TodoCtrl">
    <button ng-repeat="color in colors" ng-style="{'background-color':color}" ng-click="ChangeBgColor(color)">
      {{color}}
    </button>
</div>

JavaScript

function TodoCtrl($scope) {
  $scope.colors = ['#ddd', '#b2b2b2', '#0c60ee', '#0a9dc7', '#28a54c', '#e6b500', '#e42112', '#6b46e5', '#111', 'orange', 'yellow', 'maroon', 'green', 'brown', 'lightblue'];
 $scope.ChangeBgColor = function(selectedColor)
   {
     console.log(selectedColor);
     //$scope.selectedProduct.bgcolor = selectedColor;  
   }
}