client/app/gallery/gallery_controller.js
author cavaliet
Thu, 02 Oct 2014 13:24:57 +0200
changeset 1 74bbdd739878
parent 0 cef349423167
child 3 18a4c598ddee
permissions -rw-r--r--
views, path, search...

(function(){
  'use strict';

  angular.module('ammicoGallery',['ngResource', 'ngRoute'])
    .config(function ($routeProvider) {
      $routeProvider
        .when('/', {
          templateUrl: 'gallery/gallery.html',
          controller: 'galleryCtrl'
        });
    })
    .service('galleryApi', function($resource, context) {
      this.gallery = $resource(context.urls.galleryUrl);
    })
    .service('galleryModel', function(galleryApi, context) {
      console.log('4', context.gallery);
      if(typeof context.gallery === 'undefined') {
        console.log('4-1');
        this.gallery = galleryApi.gallery.get();
      }
      else {
        console.log('4-2');
        this.gallery = new galleryApi.gallery(context.gallery);
      }
    })
    .controller('galleryCtrl', function($scope, $location, galleryModel){
      console.log('5',$scope, $location, galleryModel);
      $scope.gallery = galleryModel.gallery;
    });

})();