Hi, I'm a n00b to Angular and have been working through the below tutorial 
to get my head around things:
http://jphoward.wordpress.com/2013/01/05/end-to-end-web-app-in-under-an-hourpart-3/

Having adapted the the tutorial to my needs I am experiencing the below 
error and am struggling to find a solution. My understanding is that it is 
something to do with the Factory, originally I thought this was this could 
have been a malformed API request but I seem to be getting the right result 
in the browser.

Error: [$resource:badcfg] Error in resource configuration. Expected 
> response to contain an object but got an array
>

Any help would be appreciated.

My app.js code is:

//Main App
>
> var app = angular.module("FixturesApp", ['ngRoute', 'ngResource']).
>
> config(function ($routeProvider) {
>
>
>>     //Routing
>
>     $routeProvider
>
> .when('/', { templateUrl: 'list.html', controller: ListCtrl })
>
> .otherwise({ redirectTo: '/' });
>
> });
>
>
>>
>> //Factory
>
> app.factory('Fixture', function ($resource) {
>
>     return $resource('/api/fixtures/:id', { id: '@id'}, { update: { 
>> method: 'PUT' } });
>
> });
>
>
>> //Directive
>
> app.directive('sorted', [
>
>     function() {
>
>         return {
>
>             scope: true,
>
>             restrict: 'A',
>
>             transclude: true,
>
>             template: '<a class="btn btn-link" ng-click="do_sort()" 
>> ng-transclude></a>' +
>
>                 '<span ng-show="do_show(true)">' +
>
>                 '<i class="glyphicon glyphicon-arrow-down"></i>' +
>
>                 '</span>' +
>
>                 '<span ng-show="do_show(false)">' +
>
>                 '<i class="glyphicon glyphicon-arrow-up"></i>' +
>
>                 '</span> ',
>
>             controller: function($scope, $element, $attrs) {
>
>                 $scope.sort_by = $attrs.sorted;
>
>
>>                 $scope.do_sort = function() {
>
>                     $scope.sort($scope.sort_by);
>
>                 };
>
>
>>                 $scope.do_show = function(is_desc) {
>
>                     return (is_desc != $scope.is_desc && $scope.sort_order 
>> == $scope.sort_by)
>
>                 }
>
>             }
>
>         };
>
>     }
>
> ]);
>
>
>> //Controller
>
> var ListCtrl = function ($scope, $location, Fixture) {
>
>     $scope.sort_order = "Id";
>
>     $scope.is_desc = false;
>
>
>>     $scope.sortString = function (is_desc) {
>
>         return is_desc ? "-" : "";
>
>     }
>
>
>>     $scope.sort = function (col) {
>
>         if ($scope.sort_order === col) {
>
>             $scope.is_desc = !$scope.is_desc;
>
>         } else {
>
>             $scope.is_desc = false;
>
>             $scope.sort_order = col;
>
>         }
>
>         $scope.search($scope.is_desc);
>
>     }
>
>
>>     $scope.search = function (is_desc) {
>
>         var fixtureList = Fixture.get({ order: $scope.sortString(is_desc) 
>> + $scope.sort_order }, function() {
>
>             $scope.items = fixtureList.results;
>
>         });
>
>     }
>
>
>>     $scope.search(false);
>
>
>> }
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to