I am using WebAPI on the server side:
public int Get(int productId)
{
//removed the actual logic to simplify the example
return 101;
}
The Angular:
$scope.showDetails = function (product) {
$scope.selectedProduct = product;
var queryArgs = { productId: product.id };
$scope.averageQuantity = Quantity.query(queryArgs, function() {
//callback function
console.log($scope.averageQuantity); // this shows a promise instead of an actual object
//and then open modal and pass the $scope as a parameter
});
};
//the resource:
.factory('Quantity', ['$resource', function ($resource) {
return $resource('/api/quantity', {}, { 'query': { method: 'GET', isArray: false } });
}])
Instead of the number 101 I see the promise: {"0":"1","1":"0","2":"1"}
How can I implement the callback in order to see the object and not the promise?