iarjunsk/ionic-firebase-shopping-cart

Categories sorting

Closed this issue · 0 comments

I added this code to the controller.js in order to sort items by their categories, but it doesn't do anything.

.controller('filterByCtrl', function($scope,sharedFilterService) {

  $scope.Categories = [
    {id: cat01, name: 'Burger'},
    {id: cat01, name: 'Drinks'}
  ];
  
  $scope.getCategory = function(cat_list){
    categoryAdded = cat_list;
	var c_string=""; // will hold the category as string
	
	for(var i=0;i<categoryAdded.length;i++){ c_string+=(categoryAdded[i].id+"||"); }
	
	c_string = c_string.substr(0, c_string.length-2);
	sharedFilterService.category=c_string;
	window.location.href = "#/page1";
  };
	

})

Any clue how I can sort the products based on their categories?