Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="colorChooser">
- <div class="slimshady" ng-click="">orange</div>
- <div class="slimshady" ng-click="">purple</div>
- <div class="slimshady" ng-click="">black</div>
- <div class="slimshady" ng-click="">blue</div>
- <div class="slimshady" ng-click="">white</div>
- </div>
- <div ng-controller = "MyController">
- <input type="text" ng-model="searchTerm">
- <div class="items">
- <div ng-repeat-start="row in colors track by $index " class="row">
- <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">
- <span>
- <img class="img-responsive" ng-src="images/colors/{{item.number}}.jpg">
- {{item.number}}
- </span>
- </div>
- </div>
- <div ng-repeat-end ng-show="selected && selectedRowIndex==$index" class="row item-tr item-tr-{{selectedColumnIndex}}">
- <div>
- <h2>{{selected.bio}}</h2>
- <h2>{{selected.basecolor}}</h2>
- </div>
- </div>
- </div>
- <div ng-repeat="item in colors "></div>
- </div>
- var myApp = angular.module('ProjectAssembly', []);
- myApp.controller('MyController', ['$scope', '$http', function($scope, $http) {
- $http.get('data/color.json').success (function (data){
- $scope.colors=data;
- $scope.colors = (function(data) {
- var result = [];
- angular.forEach(data, function(val, index) {
- var key = Math.floor(index / 4);
- if (!result[key]) {
- result[key] = [];
- }
- result[key].push(val);
- });
- return result;
- })($scope.colors);
- $scope.select = function(item, rowIndex, columnIndex) {
- if (item == $scope.selected) {
- $scope.selected = null;
- $scope.selectedRowIndex = null;
- $scope.selectedColumnIndex = null;
- return false;
- }
- $scope.selected = item;
- $scope.selectedRowIndex = rowIndex;
- $scope.selectedColumnIndex = columnIndex;
- };
- $scope.isActive = function(item) {
- return $scope.selected === item;
- };
- });
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement