Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
resolve: {
  document: function ($stateParams, specialGet, $http) {
    var id = $stateParams.id      
    return specialGet(id)
  },
},

.factory('specialGet', function (Pusher, $q, $http) {
  return function (id) {
    return 
      $http.get('/api/document/'+id)
  }
})

When I inject document into my controller I get an object with these properties

config: Object
data: Object
headers: function (name) {
status: 200
statusText: "OK"

How do I pass just the data into document instead of the return being this object and having to get the data afterwards?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Continue on the http promise using the then method, and return the desired data there.

resolve: {
  document: function ($stateParams, $http) {
    var nid = $stateParams.id      
    return $http.get('/api/document/'+id).then(function(response) { return response.data; });
  },
},
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.