I am note sure as I have never used CouchDB but from a little research
don't you delete using the the following..
http.delete('http://127.0.0.1:5984/customers/<http://127.0.0.1:5984/customers/_all_docs?include_docs=true/>'
+ id).then(...
Also from the look of the code the id is never being used?
id = {"id": "customers.id"};
this would make id
{"id": "customers.id"}
and not:
{"id": '13ce4780-62c8-4074-9955-8c99966b84bb'}
Regards,
Garry Taylor
see: http://elegantcode.com/2009/07/03/delete-documents-from-couchdb/
On Thursday, 15 May 2014 20:14:10 UTC+1, Mathias Christensen wrote:
>
> Hello everyone.
> This is my controller which provides the information from the Couchdb to
> the front-end view. So far it works to list all the customers. But I wanna
> make it possible to delete single customers by ID from the
> database(whatever) couchdb.
> Right now with this code, when i click the ng-click="remove(customers.id)"
> it removes the single customer from the view, but as soon as I update the
> page, the data comes back. I dont know know how to make this work, someone
> please help. I appreciate it! :-)
>
>
> customerListApp.controller('customerListCtrl', ['$scope', '$http',
> function (scope, http) {
>
> http.get('
> http://127.0.0.1:5984/customers/_all_docs?include_docs=true').success(function(data)
> {
> scope.customerList = data.rows;
>
> scope.sortField = 'company';
> scope.reverse = true;
> });
>
> scope.remove = function (id) {
> id = {"id": "customers.id"};
> http.delete('
> http://127.0.0.1:5984/customers/_all_docs?include_docs=true/', id);
> scope.customerList.splice(id, 1)
> }
>
> }]);
>
> In my HTML page it looks like this:
>
> <tr ng-repeat="customers in customerList | filter:query |
> orderBy:sortField:reverse">
> <td>{{customers.doc.company}}</td>
> <td>{{customers.doc.cpr}}</td>
> <td>{{customers.doc.username}}</td>
> <td>{{customers.doc.address}}</td>
> <td><a href="/customerList/editCustomer.html"
> ng-click="editCustomers(customers.id)" class="btn btn-small
> btn-primary">Edit/Update</a></td>
> <td><a ng-click="remove(customers.id)" class="btn
> btn-small btn-danger" style="width:100px;">Delete
> {{customers.doc.company}}</a></td>
> <td><a href="/customerLicense/viewLicense.html"
> ng-click="viewLicense(customers._id)" class="btn btn-small btn-primary"
> id="btnstyle">View {{customers.doc.company}}'s license</a></td>
> </tr>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.