Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Gallery Module
  3.  *
  4.  * Declare the gallery module here, specify dependencies
  5.  * and configure the module.
  6.  */
  7. 'use strict';
  8.  
  9. /* @ngInject */
  10. function config($stateProvider) {
  11.   $stateProvider
  12.     .state('gallery-view', {
  13.       url: '/photo-gallery-flip/:slug/:slide',
  14.       scrollTo: 'top',
  15.       controller: 'GalleryCtrl',
  16.       controllerAs: 'gallery',
  17.       resolve: GalleryCtrl.resolve,
  18.       templateUrl: '/assets/js/angular-src/app/gallery/gallery-view.tpl.html'
  19.     });
  20. }
  21.  
  22. angular
  23.   .module('app.gallery', [
  24.       'ui.router',
  25.       'ngResource'
  26.   ])
  27.   .config(config);
  28.  
  29.  
  30. /**
  31.  * Gallery Controller
  32.  *
  33.  * This is where your gallery business logic will go. This file
  34.  * should not get bloated. Try and keep majority of code & logic
  35.  * in your services.
  36.  */
  37. 'use strict';
  38.  
  39. /* @ngInject */
  40. function GalleryCtrl($stateParams, GalleryService, gallery) {
  41.   this.gallery = gallery;
  42.   ...
  43. };
  44.  
  45. /**
  46.  * Before the Gallery is instantiated, resolve some dependencies,
  47.  * like requesting the gallery from the api.
  48.  */
  49. GalleryCtrl.resolve = {
  50.   fetch: function($stateParams, GalleryService) {
  51.     return GalleryService.fetch($stateParams.slug);
  52.   },
  53.   gallery: function($stateParams, GalleryService) {
  54.     return GalleryService.getGallery($stateParams.slug);
  55.   }
  56. };
  57.  
  58. angular
  59.   .module('app.gallery')
  60.   .controller('GalleryCtrl', GalleryCtrl);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement