Subversion Repositories SmartDukaan

Rev

Rev 13557 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13557 Rev 13560
Line 5... Line 5...
5
// the 2nd parameter is an array of 'requires'
5
// the 2nd parameter is an array of 'requires'
6
// 'starter.services' is found in services.js
6
// 'starter.services' is found in services.js
7
// 'starter.controllers' is found in controllers.js
7
// 'starter.controllers' is found in controllers.js
8
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.filters', 'LocalStorageModule','ngResource'])
8
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.filters', 'LocalStorageModule','ngResource'])
9
 
9
 
10
.run(function($ionicPlatform,$rootScope) {
10
.run(function($ionicPlatform,$rootScope,Clicks,localStorageService) {
11
  $rootScope.likeProduct = function(id){
11
  $rootScope.likeProduct = function(id){
12
    alert('like '+id);
12
    // alert('like '+id);
13
    console.log(id);
13
    // $scope.click = Clicks.get({'me':localStorageService.get('me'),'id':id});    
14
  },
14
  },
15
  $rootScope.unlikeProduct = function(id){
15
  $rootScope.unlikeProduct = function(id){
16
    alert('unlike '+id);
16
    alert('unlike '+id);
17
    console.log(id);
17
    console.log(id);
18
  }
18
  }
19
  $rootScope.viewproduct = function(id){
19
  $rootScope.viewproduct = function(id){
-
 
20
    Clicks.get({'me':localStorageService.get('me'), 'id':id},  
-
 
21
      function( result ) {          
20
    alert('view product '+id);
22
        console.log(result);
-
 
23
        if(result.success && result.type == 'redirect'){
-
 
24
          document.location = result.url;
-
 
25
        }
-
 
26
      },
-
 
27
      function( error ) {
-
 
28
        console.log( "Something went wrong!" );
-
 
29
      }
-
 
30
    );
21
  } 
31
  } 
22
  $rootScope.chunk = function(arr, size) {
32
  $rootScope.chunk = function(arr, size) {
23
    var newArr = [];
33
    var newArr = [];
24
    for (var i=0; i<arr.length; i+=size) {
34
    for (var i=0; i<arr.length; i+=size) {
25
      newArr.push(arr.slice(i, i+size));
35
      newArr.push(arr.slice(i, i+size));