0
當我嘗試加載此控制器:角JS錯誤而載入資源
.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();
});
我得到這個錯誤在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
也許你的資源正在返回一個數組而不是一個對象? –
這個問題似乎在用戶服務中。請分享這段代碼。 –
@DavidFigueroa繼承人服務: https://jsfiddle.net/javiroberts/to5dg0ta/ –