Admittedly I am relatively new to Angular but I've come unstuck using ngResource for a REST call.

I followed a factory pattern which seems to be relatively common.

However my I only get access to the REST response by using a $promise.then. Which I understand you do not require with $resource.

So I have this factory...

```
var LookupsService = angular.module('LookupsService', ['ngResource']);

LookupsService.factory('Lookups', ['$resource',
  function ($resource) {
      return $resource('http://localhost:5001/api/lookups', {});
  }]);

```

And this fails (as undefined)

```
alert(Lookups.get().foo);

```

But this is fine

```
    Lookups.get()
        .$promise
        .then(function (lookups) {
            alert(lookups.foo);
        });

```

I'm obviously missing something here. Some kind of schoolboy error ;-)

**UPDATE**

Thanks for all your help - it is now very clear. I gave @fikkatra the tick for the clarity of her answer and snippet. But pretty much all the answers were helpful. I must be careful using Alert for debugging!