Created
March 17, 2015 01:00
-
-
Save LateButEarly/6dd1477a858f0fccf8a7 to your computer and use it in GitHub Desktop.
please create a comment D:
This file contains 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
$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