documentation

angular
Matt Huntington 10 years ago
parent 4d073df1eb
commit cd06597fdd

@ -54,7 +54,7 @@ app.controller('TransgressionsController', ['$http', function($http){
description: this.newTransgressionDescription description: this.newTransgressionDescription
} }
}).success(function(data){ }).success(function(data){
//once response to create transgression comes back, //once response to create transgression comes back,
//pop off what was pushed at beginning of this.createTransgression //pop off what was pushed at beginning of this.createTransgression
//push the response's data on... //push the response's data on...
controller.current_user_transgressions.pop(); controller.current_user_transgressions.pop();
@ -64,7 +64,9 @@ app.controller('TransgressionsController', ['$http', function($http){
}); });
} }
// create a confession for a transgression identified by transgression_id
this.createConfession = function(transgression_id){ this.createConfession = function(transgression_id){
//AJAX call using parameter that identifies transgression
$http.post('/transgressions/'+transgression_id+'/confessions', { $http.post('/transgressions/'+transgression_id+'/confessions', {
//include authenticity_token //include authenticity_token
authenticity_token: authenticity_token, authenticity_token: authenticity_token,
@ -73,6 +75,7 @@ app.controller('TransgressionsController', ['$http', function($http){
occurred_at: this.newConfessionDate occurred_at: this.newConfessionDate
} }
}).success(function(data){ }).success(function(data){
//refresh transgression data once POST is complete
getTransgressions(); getTransgressions();
}); });
} }

@ -17,6 +17,7 @@
When: {{confession.occurred_at}} When: {{confession.occurred_at}}
</li> </li>
</ul> </ul>
<!-- Confessions go are displayed/created -->
<h3>Add a confession (yum):</h3> <h3>Add a confession (yum):</h3>
<form ng-submit="transgressionsCtrl.createConfession(transgression.id)"> <form ng-submit="transgressionsCtrl.createConfession(transgression.id)">
<input type="text" ng-model="transgressionsCtrl.newConfessionDescription" placeholder="How did you please me?"/> <input type="text" ng-model="transgressionsCtrl.newConfessionDescription" placeholder="How did you please me?"/>

Loading…
Cancel
Save