client/app/gallery/gallery_controller.js
author ymh <ymh.work@gmail.com>
Wed, 11 Jun 2014 01:26:59 +0200
changeset 0 cef349423167
child 1 74bbdd739878
permissions -rw-r--r--
add basic file org + client prototype
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
(function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
  'use strict';
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
  angular.module('ammicoGallery',['ngResource', 'ngRoute'])
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
    .config(function ($routeProvider) {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
      $routeProvider
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
        .when('/', {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
          templateUrl: 'gallery/gallery.html',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
          controller: 'galleryCtrl'
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
        });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
    })
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
    .service('galleryApi', function($resource, context) {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
      this.gallery = $resource(context.urls.galleryUrl,
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
        {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
          get: {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
            method: 'GET',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
            isArray: false
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
          }
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
        });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    })
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    .service('galleryModel', function(galleryApi, context) {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
      console.log('4', context.gallery);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
      if(typeof context.gallery === 'undefined') {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
        console.log('4-1');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
        this.gallery = galleryApi.gallery.get();
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
      }
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
      else {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
        console.log('4-2');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
        this.gallery = new galleryApi.gallery(context.gallery);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
      }
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
    })
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
    .controller('galleryCtrl', function($scope, $location, galleryModel){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
      console.log('5',$scope, $location, galleryModel);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
      $scope.gallery = galleryModel.gallery;
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
    });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
})();