Javi Roberts
Javi Roberts

Reputation: 1

Angular JS error while loading resource

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

Upvotes: 0

Views: 133

Answers (1)

user6603822
user6603822

Reputation: 11

Try to use query instead of get:

$scope.user = User.query({id:$stateParams.id});

Upvotes: 1

Related Questions