|
0
|
1 |
(function(){ |
|
|
2 |
'use strict'; |
|
|
3 |
|
|
|
4 |
angular.module('ammicoGallery',['ngResource', 'ngRoute']) |
|
|
5 |
.config(function ($routeProvider) { |
|
|
6 |
$routeProvider |
|
|
7 |
.when('/', { |
|
|
8 |
templateUrl: 'gallery/gallery.html', |
|
|
9 |
controller: 'galleryCtrl' |
|
|
10 |
}); |
|
|
11 |
}) |
|
|
12 |
.service('galleryApi', function($resource, context) { |
|
1
|
13 |
this.gallery = $resource(context.urls.galleryUrl); |
|
0
|
14 |
}) |
|
|
15 |
.service('galleryModel', function(galleryApi, context) { |
|
|
16 |
console.log('4', context.gallery); |
|
|
17 |
if(typeof context.gallery === 'undefined') { |
|
|
18 |
console.log('4-1'); |
|
|
19 |
this.gallery = galleryApi.gallery.get(); |
|
|
20 |
} |
|
|
21 |
else { |
|
|
22 |
console.log('4-2'); |
|
|
23 |
this.gallery = new galleryApi.gallery(context.gallery); |
|
|
24 |
} |
|
|
25 |
}) |
|
|
26 |
.controller('galleryCtrl', function($scope, $location, galleryModel){ |
|
|
27 |
console.log('5',$scope, $location, galleryModel); |
|
|
28 |
$scope.gallery = galleryModel.gallery; |
|
|
29 |
}); |
|
|
30 |
|
|
|
31 |
})(); |