I have ran into a wall with this. This is my delete function from my mainController.
$scope.delete = function($posts) {
$http.delete('/api/posts/' + $posts._id)
.success(function(data) {
// delete element from DOM
// on success I want to delete the post I'm clicking on.
});
And here is the template where I load my data with angular.
<div id="post-stream">
<h4>Chirp Feed</h4>
<div class="post" ng-repeat="post in posts.results | orderBy:'created_at':true" ng-class-odd="'odd'" ng-class-even="'even'">
<button ng-click="delete(post)" ng-show="authenticated" class="btn btn-danger btn-xs pull-right remove">x</button>
<p>{{post.text}}</p>
<small>Posted by @{{post.created_by}}</small>
<small class="pull-right">{{post.created_at | date:"h:mma 'on' MMM d, y"}}</small>
</div>
</div>
I can delete the posts in my database but I can't figure out how to delete the element I'm clicking on.