Subversion Repositories SmartDukaan

Rev

Rev 13551 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

angular.module('starter.controllers', [])

.controller('DashCtrl', function($scope, $stateParams, Categories, CategoryProducts, localStorageService) {  
  $scope.me = localStorageService.get('me');
  $scope.categories = Categories.all({'me':$scope.me});
  $scope.products = CategoryProducts.all({'me':$scope.me});    
  // $scope.$on('$stateChangeSuccess', function() {
  //   console.log("state changed");
  // });  
  $scope.hasProducts = function(categoryId,products) {
    for(index in products) {
      // console.log(products[index].Product.category_id);
      // console.log(objects[index].Product.category_id)
      if(products[index].Product.category_id == categoryId) // filter by name only
        return true;
    }
  }
})

.controller('ChatsCtrl', function($scope, Products, localStorageService) {
  $scope.me = localStorageService.get('me');
  console.log($scope.me);
  $scope.products = Products.all({'me':$scope.me});  
  $scope.loadmore = function(){
    console,log('load more');
  }
})

.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
  $scope.chat = Chats.get($stateParams.chatId);
})

.controller('FriendsCtrl', function($scope, Friends) {
  $scope.friends = Friends.all();
})

.controller('FriendDetailCtrl', function($scope, $stateParams, Friends) {
  $scope.friend = Friends.get($stateParams.friendId);
})

.controller('AccountCtrl', function($scope) {
  $scope.settings = {
    enableFriends: true
  };
})
.controller('LoginCtrl', function($scope,$location,localStorageService) {
  $scope.me = $location.search().user_id;
  if($scope.me){
    console.log($scope.me);
    localStorageService.set('me',$scope.me); 
    $location.path("/tab/chats");    
  }  
});