you need to call some function (rest, for example) to delete this register
in your database, the angular part is working perfectly.


2014-05-15 9:34 GMT-03:00 Mathias Christensen <[email protected]>:

> I just tried that, and still doesn't seem to work. But I figured something
> out. I tried this:
>
> var customerListApp = angular.module('customerListApp', []);
>
> 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) {
>             scope.customerList.splice(id, 1)
>         }
>
>     }]);
>
>
> This little form -  scope.remove = function (id) {
>             scope.customerList.splice(id, 1)
>         }
> - Deletes the object from the view which I wanted it to. BUT, when I
> refresh the page, the data comes back. I want to delete the information
> completely from couchdb. Any advice here?
>
>
>
>
> Den torsdag den 15. maj 2014 14.17.21 UTC+2 skrev Filipe Monteiro:
>>
>> have you tried like this:
>>
>> customerListApp.controller('customerListCtrl', ['$scope', '$http',
>>     function (scope, http) {
>>
>>         scope.remove = function (id) {
>>             for (i in customers) {
>>                 if (customers[i].id == id) {
>>                     customers.splice(i, 1);
>>                 }
>>             }
>>         }
>>
>>     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;
>>     });
>>
>>
>>     }]);
>>
>> It should work.
>>
>>
>> 2014-05-15 9:13 GMT-03:00 Mathias Christensen <[email protected]>:
>>
>>> I've done that, but still not working. I do have in mind, that maybe I
>>> should store my data before it can get it by id or something? I'm quite new
>>> to angularjs :/
>>>
>>> Den torsdag den 15. maj 2014 14.09.19 UTC+2 skrev Filipe Monteiro:
>>>
>>>> Your scope functions are inside of your http.get success. You should
>>>> put those functions out of this promise.
>>>>
>>>> Em quinta-feira, 15 de maio de 2014 08h45min59s UTC-3, Mathias
>>>> Christensen escreveu:
>>>>>
>>>>> Hello everyone! I'm using Couchdb to store my data. and
>>>>> createNewCustomer + the list of customers works fine. I need help to 
>>>>> delete.
>>>>>
>>>>> This is my ng-click:
>>>>>
>>>>>
>>>>>     ---->>        <td><a ng-click="remove(customers.id)" class="btn
>>>>> btn-small btn-danger" style="width:100px;">Delete
>>>>> {{customers.doc.company}}</a></td>
>>>>>
>>>>> I've tried a lot of stuff inside my controller, and this is what I got
>>>>> so far. This is both the listing and now I want to add the delete function
>>>>> inside same ctrl.:
>>>>>
>>>>>
>>>>> var customerListApp = angular.module('customerListApp', []);
>>>>>
>>>>> 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;
>>>>>
>>>>> ---------------vvvvvvvvvvvvvvvvvvv---------------------------
>>>>>
>>>>>         scope.remove = function (id) {
>>>>>             for (i in customers) {
>>>>>                 if (customers[i].id == id) {
>>>>>                     customers.splice(i, 1);
>>>>>                 }
>>>>>             }
>>>>>         }
>>>>>
>>>>>
>>>>>
>>>>>     });
>>>>>     }]);
>>>>>
>>>>>
>>>>>
>>>>> It seems like nothing is happening when I click the button. Help! :)
>>>>>
>>>>  --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "AngularJS" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/angular/CGfo4fBKm4k/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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.
>>>
>>
>>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/CGfo4fBKm4k/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

-- 
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.

Reply via email to