Subversion Repositories SmartDukaan

Rev

Rev 13551 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13542 anikendra 1
angular.module('starter.controllers', [])
2
 
3
.controller('DashCtrl', function($scope, $stateParams, Categories, CategoryProducts, localStorageService) {  
4
  $scope.me = localStorageService.get('me');
5
  $scope.categories = Categories.all({'me':$scope.me});
6
  $scope.products = CategoryProducts.all({'me':$scope.me});    
7
  // $scope.$on('$stateChangeSuccess', function() {
8
  //   console.log("state changed");
9
  // });  
10
  $scope.hasProducts = function(categoryId,products) {
11
    for(index in products) {
12
      // console.log(products[index].Product.category_id);
13
      // console.log(objects[index].Product.category_id)
14
      if(products[index].Product.category_id == categoryId) // filter by name only
15
        return true;
16
    }
17
  }
18
})
19
 
20
.controller('ChatsCtrl', function($scope, Products, localStorageService) {
21
  $scope.me = localStorageService.get('me');
22
  console.log($scope.me);
23
  $scope.products = Products.all({'me':$scope.me});  
24
  $scope.loadmore = function(){
25
    console,log('load more');
26
  }
27
})
28
 
29
.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
30
  $scope.chat = Chats.get($stateParams.chatId);
31
})
32
 
33
.controller('FriendsCtrl', function($scope, Friends) {
34
  $scope.friends = Friends.all();
35
})
36
 
37
.controller('FriendDetailCtrl', function($scope, $stateParams, Friends) {
38
  $scope.friend = Friends.get($stateParams.friendId);
39
})
40
 
41
.controller('AccountCtrl', function($scope) {
42
  $scope.settings = {
43
    enableFriends: true
44
  };
45
})
46
.controller('LoginCtrl', function($scope,$location,localStorageService) {
47
  $scope.me = $location.search().user_id;
48
  if($scope.me){
49
    console.log($scope.me);
50
    localStorageService.set('me',$scope.me); 
51
    $location.path("/tab/chats");    
52
  }  
53
});