Skip to content

Instantly share code, notes, and snippets.

@agamdua
Last active August 29, 2015 13:56
Show Gist options
  • Save agamdua/5deae704d4a03575dd17 to your computer and use it in GitHub Desktop.
Save agamdua/5deae704d4a03575dd17 to your computer and use it in GitHub Desktop.
Here is the attempt where the URL is working
<li class="active"><a>Location</a>
<ul class="nav">
<li ng-repeat="filterout in searchResults.Filters.Location">
<div class>
<input id="{{filterout}}" type="checkbox" name="check" ng-click="getCheckBoxes()">
<label for="{{filterout}}" class="checklabel">
{{filterout}}
</label>
</div>
</li>
</ul>
</li>
app.controller('populateSearchController',['$location','$scope','$http','$resource','$routeParams','commonFactory',function($location,$scope,$http,$resource,$routeParams,commonFactory){
//start code of controller
$scope.numberOfPages = calculatePages(totalItems);
// blah blah all upto this line is before function
$scope.getCheckBoxes = function () { //yep, this is the function
var counter = 0;
$scope.storeCheckBoxes = {};
console.log("On declaration type = " + typeof($scope.storeCheckBoxes));
$('input[type=checkbox]').each(function (counter) {
console.log("inside jQuery type = " + typeof($scope.storeCheckBoxes));
// console.log("This = " + $(this));
if($(this).is(":checked")) {
console.log("inside if type = " + typeof($scope.storeCheckBoxes));
counter++;
console.log("Filter = " + $(this).attr('id'));
var filterParam = "p" + counter;
$scope.storeCheckBoxes[filterParam] = $(this).attr('id');
}
}
);
var searchDict = $location.search();
// console.log(searchDict);
var newSearchDict = angular.extend(searchDict, $scope.storeCheckBoxes);
console.log(newSearchDict);
$location.path('search/products').search(newSearchDict);
};
// this is where the rest starts:
function fetchDummyResults ($resource) {
// blah blah
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment