You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
var app = angular.module('SinsApp', []);
|
|
|
|
app.controller('HeaderController', ['$http', function($http){
|
|
var controller = this;
|
|
$http.get('/session').success(function(data){
|
|
controller.current_user = data.current_user;
|
|
});
|
|
}]);
|
|
|
|
app.controller('TransgressionsController', ['$http', function($http){
|
|
var controller = this;
|
|
$http.get('/transgressions').success(function(data){
|
|
controller.transgressions = data.transgressions;
|
|
});
|
|
|
|
this.SIN_TYPES = [ 'Gluttony', 'Greed', 'Anger', 'Pride', 'Lust', 'Sloth', 'Envy'];
|
|
this.newTransgressionSinType = 'Gluttony';
|
|
|
|
this.createTransgression = function(){
|
|
var csrf = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
|
$http.post('/transgressions', {
|
|
authenticity_token: csrf,
|
|
transgression: {
|
|
sin_type: controller.newTransgressionSinType,
|
|
description: controller.newTransgressionDescription
|
|
}
|
|
}).success(function(data){
|
|
$http.get('/transgressions').success(function(data){
|
|
controller.transgressions = data.transgressions;
|
|
});
|
|
});
|
|
}
|
|
}]);
|