Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with $http service in Angular 1.2
    primarykey
    data
    text
    <p>I just started using Angular 1.2.0 in my development app, and I noticed that the following function doesn't work anymore, take a look:</p> <pre><code>var myItems = angular.model('myItems', []); myItems.controller('itemsController', function($scope, $http) { // delete item from the database $scope.deleteItem = function(id) { $http.delete('/api/items/' + id) .success(function(data) { $scope.items = data; }) .error(function(data) { // log error }); }; }); </code></pre> <p>Then in my view, this is what triggers deleting an item:</p> <pre><code>&lt;input type="checkbox" data-ng-click="deleteItem(item._id)"&gt; {{ item.text }} </code></pre> <p>I'm very fresh to Angular, so I'm not sure what's exactly going wrong here, and a look at the <a href="https://github.com/angular/angular.js/blob/master/CHANGELOG.md" rel="nofollow">changelog</a> file for version 1.2 on the Angular repository didn't yield an answer. Can somebody with more experience in Angular please explain to me what exactly the problem is here?</p> <p><strong>Edit</strong>: here's the log from the Chrome error console, which is visible as soon as the page is loaded. Clicking the checkbox to delete an item does nothing.</p> <pre><code>Error: [$parse:isecprv] http://errors.angularjs.org/undefined/$parse/isecprv?p0=deleteItem(item._id) at Error (&lt;anonymous&gt;) at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:6:453 at ha (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:84:103) at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:87:372 at Array.forEach (native) at q (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:7:261) at rc (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:87:354) at Jb.readIdent (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:149:31) at Jb.lex (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:144:199) at Ya.parse (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:151:12) &lt;input type="checkbox" data-ng-click="deleteItem(item._id)"&gt; </code></pre> <p><strong>Update</strong>: It turns out that one of the breaking changes in <strong>Angular 1.2.0-rc2</strong> (currently latest stable build) is the introduction of private properties on the scope chain. This potentially breaks a lot of apps that stores data in document-oriented databases such as, in my case <code>MongoDB</code>. If you're someone facing this same issue, you can either go back to version <strong>1.2.0-rc3</strong> (Google CDN <a href="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js" rel="nofollow">here</a>) for now or wrap your sensitive APIs in a closure/controller as suggested in the changelog.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload