Note that there are some explanatory texts on larger screens.

plurals
  1. POangular error : object has no method push
    primarykey
    data
    text
    <p>I am trying to make a angular work with a REST service and <code>$resource</code>. </p> <p>it works to GET the datas from JSON, but when updating whith <code>$save()</code> or a custom method called <code>$rec()</code>, i have an error in the console saying : <code>TypeError: Object #&lt;c&gt; has no method 'push'</code>. Switching <code>isArray</code> to <code>true</code> or <code>false</code>, didn't change anything. </p> <p>i made a plunker : <a href="http://plnkr.co/edit/fS2bjRKPgUulTbTxgg2j" rel="nofollow">http://plnkr.co/edit/fS2bjRKPgUulTbTxgg2j</a></p> <p>the error is visible when you make it run on your own server. </p> <p>the html: </p> <pre><code>&lt;div ng-controller="TestCtrl"&gt; &lt;div ng-repeat="obj in objs"&gt; &lt;div&gt; &lt;h3&gt;{{obj.name}}&lt;/h3&gt; &lt;h3&gt;{{obj.age}}&lt;/h3&gt; &lt;input type="text" ng-model="obj.name" /&gt;&lt;br /&gt; &lt;input type="text" ng-model="obj.age" /&gt;&lt;br /&gt; &lt;button ng-click="save(obj)"&gt;Save&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and the javascript: </p> <pre><code>'use strict'; angular.module('TestApp', ['TestApp.services', 'TestApp.controllers']); angular.module('TestApp.services', ['ngResource']). factory('Obj', function($resource){ return $resource('datas.json', {}, { 'rec': {method: 'POST', isArray: true } }); }); angular.module('TestApp.controllers', []). controller('TestCtrl', ['$scope', 'Obj', function($scope, Obj) { $scope.objs = Obj.query(); $scope.save = function(obj) { obj.$save(); console.log(obj); } }]); </code></pre> <p>do you know where the error comes from ? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    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