I return a resource with a URL
$resource(\"http://foo.com/bar.json\").get().
$promise.then(function(data){ $scope.result = data},
So in case someone else is stumbling here and didn't understand promises/angularjs here is what is going on. When you use .then()
or .get()
you get a promise and some helper functions all in the same object. This is awesome because then you don't worry about callbacks being defined and whether data is available because the promise object always has some properties. This object contains your raw data in another object within. So the promise object is nested, you just have to reference the data object within when the data is ready.
Here's what I was doing
$resource("http://foo.com/bar.json").get().
$promise.then(function(data){ $scope.result = data},
//data is actually a promise object.
function(error){ $scope.msg = "error" } );
promise object
Note the data is actually under another object called "data". So in your success callback to get just the data you should do in this case: data.data