Created
July 16, 2014 21:25
-
-
Save kaumac/02b8617810325da0b133 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// The Angular App | |
angular.module('kiikPanel', [ | |
'ngCookies', | |
'ngResource', | |
'ngSanitize', | |
'Devise', | |
'ngAnimate', | |
'ui.router' | |
]) | |
// Makes Lo-dash / Underscore avaiable at constant level | |
.constant('_', window._) | |
// Angular app configuration | |
.config(['$httpProvider', '$stateProvider', '$urlRouterProvider', 'AuthProvider', function ($httpProvider, $stateProvider, $urlRouterProvider, AuthProvider) { | |
$httpProvider.defaults.headers.common['X-Requested-With']; | |
$urlRouterProvider.otherwise('/'); | |
$stateProvider | |
.state('sign_in', { | |
url: '/users/sign_in', | |
templateUrl: 'user/sign_in', | |
controller: 'LoginController', | |
noHeader: true | |
}) | |
.state('recipients', { | |
url: '/', | |
templateUrl: '/recipients', | |
controller: 'RecipientsController', | |
resolve: { | |
recipients: function(RecipientsService) { | |
return RecipientsService.getRecipients(); | |
} | |
} | |
}) | |
.state('recipient', { | |
url: '/recipient/:recipient_id', | |
templateUrl: '/views/recipient', | |
controller: 'RecipientController' | |
}) | |
}]) | |
// Declare event bindings | |
.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) { | |
$rootScope.$on('devise:unauthorized', function(event, xhr, deferred) { | |
event.preventDefault(); | |
$state.transitionTo("sign_in"); | |
}); | |
$rootScope.$on('devise:logout', function(event, oldCurrentUser) { | |
event.preventDefault(); | |
$state.transitionTo("sign_in"); | |
}); | |
}]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('kiikPanel').controller('RecipientsController', ['$scope', 'recipients', function($scope, recipients) { | |
$scope.recipients = recipients.data; | |
}]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('kiikPanel').factory('RecipientsService', ['$resource', function($resource) { | |
return $resource('/api/recipients/all', null, { | |
'getRecipients': { method: 'GET' } | |
}); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment