0

When I try to load this controller:

.controller('UserEditController',function($scope,$state,$stateParams,User){

  $scope.updateUser=function(){
      $scope.user.$update(function(){
          $state.go('users');
      });
  };

  $scope.loadUser=function(){
      $scope.user=User.get({id:$stateParams.id});
  };

  $scope.loadUser();
});

I get this error in Chrome:

Error: [$resource:badcfg] http://errors.angularjs.org/1.5.7/$resource/badcfg?p0=get&p1=object&p2=array&p3=GET&p4=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fusers

9
  • maybe your resource is returning an array instead of an object? Commented Jun 27, 2016 at 23:20
  • The issue seems to be in the User service. Please share that piece of code too. Commented Jun 27, 2016 at 23:28
  • @DavidFigueroa heres the service: jsfiddle.net/javiroberts/to5dg0ta Commented Jun 27, 2016 at 23:36
  • @JaviRoberts You're passing in a function instead of an object in the $update call, inside updateUser Commented Jun 27, 2016 at 23:45
  • @anpatel and how should i pass the object? Commented Jun 27, 2016 at 23:50

1 Answer 1

1

Try to use query instead of get:

$scope.user = User.query({id:$stateParams.id});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.