I'm new to angular so I apologise is this is a dumb question. I have a WebAPI method that creates data. I would like to return an integer from this method that indicates the new resource's id. If I return the whole object it works in my angular controller, yet when I only return the int I get an object with a prototype and I can't seem to get the id. Fiddler shows my integer value in the TextView, so the answer is there, its just a matter of reading it with angular (javascript).
Any suggestions will be appreciated.
My service looks like this:
(function () {
'use strict';
var app = angular.module('app');
app.factory('itemSvc', function ($resource) {
return $resource("api/item",
{},
{
createNew:
{
method: 'POST'
}
});
})
})();
and I call it like this:
itemSvc.createNew($scope.newItem).$promise.then(
function (item) {
var y = item;
$scope.items.push(item);
},
function (error) {})