Advertisement
Guest User

Untitled

a guest
May 24th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <div class="colorChooser">
  2. <div class="slimshady" ng-click="">orange</div>
  3. <div class="slimshady" ng-click="">purple</div>
  4. <div class="slimshady" ng-click="">black</div>
  5. <div class="slimshady" ng-click="">blue</div>
  6. <div class="slimshady" ng-click="">white</div>
  7.  
  8. </div>
  9. <div ng-controller = "MyController">
  10.  
  11.  
  12. <input type="text" ng-model="searchTerm">
  13.  
  14.  
  15.  
  16.  
  17.  
  18. <div class="items">
  19. <div ng-repeat-start="row in colors track by $index " class="row">
  20. <div class="col-md-3 col-sm-3 col-lg-3 col-xs-3 item-td" ng-repeat="item in row " ng-class="{active:isActive(item)}" ng-click="select(item,$parent.$index,$index); whattoshow=!whattoshow">
  21. <span>
  22. <img class="img-responsive" ng-src="images/colors/{{item.number}}.jpg">
  23. {{item.number}}
  24. </span>
  25.  
  26.  
  27. </div>
  28. </div>
  29.  
  30. <div ng-repeat-end ng-show="selected && selectedRowIndex==$index" class="row item-tr item-tr-{{selectedColumnIndex}}">
  31. <div>
  32. <h2>{{selected.bio}}</h2>
  33. <h2>{{selected.basecolor}}</h2>
  34.  
  35. </div>
  36. </div>
  37.  
  38. </div>
  39.  
  40. <div ng-repeat="item in colors "></div>
  41.  
  42.  
  43. </div>
  44.  
  45. var myApp = angular.module('ProjectAssembly', []);
  46.  
  47. myApp.controller('MyController', ['$scope', '$http', function($scope, $http) {
  48. $http.get('data/color.json').success (function (data){
  49.  
  50.  
  51. $scope.colors=data;
  52.  
  53. $scope.colors = (function(data) {
  54. var result = [];
  55. angular.forEach(data, function(val, index) {
  56. var key = Math.floor(index / 4);
  57. if (!result[key]) {
  58. result[key] = [];
  59. }
  60. result[key].push(val);
  61. });
  62. return result;
  63. })($scope.colors);
  64.  
  65.  
  66.  
  67. $scope.select = function(item, rowIndex, columnIndex) {
  68. if (item == $scope.selected) {
  69. $scope.selected = null;
  70. $scope.selectedRowIndex = null;
  71. $scope.selectedColumnIndex = null;
  72. return false;
  73. }
  74. $scope.selected = item;
  75. $scope.selectedRowIndex = rowIndex;
  76. $scope.selectedColumnIndex = columnIndex;
  77. };
  78. $scope.isActive = function(item) {
  79. return $scope.selected === item;
  80. };
  81.  
  82.  
  83. });
  84.  
  85.  
  86.  
  87. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement