Skip to content

Instantly share code, notes, and snippets.

@LateButEarly
Created March 17, 2015 01:00
Show Gist options
  • Save LateButEarly/6dd1477a858f0fccf8a7 to your computer and use it in GitHub Desktop.
Save LateButEarly/6dd1477a858f0fccf8a7 to your computer and use it in GitHub Desktop.
please create a comment D:
$scope.createComment = function() {
// Attach current Article Object
var article = $scope.article;
// Create new Comment object
var comment = new Comments ({
body: this.body
});
// Update current Article Object
article.$update(function() {
//$location.path('articles/' + article._id);
// Save new Comment object
comment.$save(function(response) {
console.log('Comment in $save: %s', response._id);
// Redirect after save
$location.path('articles/' + article._id);
console.log('This is saving via the articles controller... createComment fx');
$scope.body = '';
}, function(errorResponse) {
// Comment errorResponse
$scope.error = errorResponse.data.message;
});
});
console.log(comment + '\n');
console.log(article);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment