listing current user transgressions

angular
Matt Huntington 10 years ago
parent 2b8f1f6625
commit cacf47b8ad

@ -15,6 +15,13 @@ app.controller('HeaderController', ['$http', function($http){
app.controller('TransgressionsController', ['$http', function($http){
//get authenticity_token from DOM (rails injects it on load)
var authenticity_token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
var controller = this;
// get transgressions for current User
$http.get('/transgressions').success(function(data){
//just add the transgressions to the controller, data comes back with sinner as well
controller.current_user_transgressions = data.transgressions;
});
// create a transgression
this.createTransgression = function(){

@ -3,6 +3,15 @@
</header>
<main ng-controller="TransgressionsController as transgressions">
<h2>This is How You've Pleased Me: Your Current Transgressions</h2>
<ul>
<li ng-repeat="transgression in transgressions.current_user_transgressions">
Sin Type: {{transgression.sin_type}}
<br/>
Description: {{transgression.description}}
</li>
</ul>
<h2>The Flesh is Weak: Admit Your Transgressions</h2>
<form ng-submit="transgressions.createTransgression()">
<input type="text" placeholder="Sin Type"/>

Loading…
Cancel
Save