title: Return integer to AngularJs from WebAPI
body: <p>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).</p>
  
  <p>Any suggestions will be appreciated.</p>
  
  <p>My service looks like this:</p>
  
  <pre><code>(function () {
      'use strict';
  
      var app = angular.module('app');
  
      app.factory('itemSvc', function ($resource) {
          return $resource("api/item",
              {},
              {
                  createNew:
                      {
                          method: 'POST'
                      }           
              });
      })
  })();
  </code></pre>
  
  <p>and I call it like this:</p>
  
  <pre><code>itemSvc.createNew($scope.newItem).$promise.then(
                  function (item) {
                      var y = item;
                      $scope.items.push(item);
                  },
                  function (error) {})
  </code></pre>