jak naprawić oczekiwaną odpowiedź zawierającą tablicę, ale otrzymującą obiekt ANgular js
Jestem nowy, więc trudno uzyskać ten błąd przy użyciu modułu zasobów po wywołaniu usługi. czy ktokolwiek może zmodyfikować mój błąd w kodzie, gdzie się mylę lub po prostu zmodyfikowałem, że to, co potrzebuje naprawić, musi być docenione.
Format danych Przychodzi: -
[
brands: Array[1]
0: Object
__v: 0
_id: "5251a4a34f232fc3902"
account_id: "525072320e32971b"
name: "Fruits"
__proto__: Object
1: Object
length: 2
categories: Array[1]
0: Object
__v: 0
_id: "5251a4a34f2323fc3902"
account_id: "5250723230e32971b"
name: "Fruits"
__proto__: Object
1: Object
length: 2
]
Błąd:-
[$ resource: badcfg] Błąd w konfiguracji zasobów. Oczekiwano odpowiedzi zawierającej tablicę, ale otrzymano obiekt
itmsFormView.html
<select class="form-control" ng-model="item.brand_id" id="itemBrand" >
<option value="">Select Brand</option>
<option ng-repeat="brand in brands" value="{{brand.brand_id}}">{{brand.name}} </option>
</select>
<select class="form-control" ng-model="item.category_id" id="itemCategory">
<option value="">Select Category</option>
<option ng-repeat="category in categories" value="{{category.brand_id}}">{{category.name}}</option>
</select>
ItemsService.js
app.factory('itemService', function ($resource) {
return {
getCategoryAndBrand : $resource("/user/categories_brands" ,{},{ TypeGetCategoryAndBrand:{method: 'get', isArray:true}})
};
});
ItemsController.js
app.controller('itemsFormController', function ($rootScope, $scope, itemService, $location, $cookies, $routeParams) {
itemService.getCategoryAndBrand.TypeGetCategoryAndBrand({}, function(response){
console.log(response);
},function(errorResponse){
console.log(errorResponse);
}
);
});