0

I intend to return few resource from a factory, but unfortunately it failed in my case. It shows the error message Entry is not a function Scope.$scope.create.

This is working code with one resource:

     angular.module('Entry').factory('Entry', function($resource) {
          return $resource('/api/entries/:id', { id: '@_id' }, {
            update: {
              method: 'PUT'
            }
          });
        });

        $scope.create = function() { 
                    var entry = new Entry({

                    });

                entry.$save(function() {});
       }

This is not working code after adding multiple resource:

 angular.module('Entry').factory('Entry', function($resource) {
      return {
            'EntryA': $resource('/api/entries/:id', { id: '@_id' }, {
                        update: {
                          method: 'PUT'
                        }
                      }), 
            'EntryB': $resource('/api/entries/:id', { id: '@_id' }, {
                        update: {
                          method: 'PUT'
                        }
                      }), 
        };
    });

      $scope.create = function() { 
                    var entry = new Entry({

                    });

                entry.EntryA.$save(function() {});
       }
stackdisplay
  • 1,949
  • 6
  • 29
  • 46
  • @georgeawg I got two errors after using that. One is `unexpected token ;` in the second line of the declaration of entryA, another is `Error: [$injector:unpr] Unknown provider: EntryProvider <- Entry` – stackdisplay Jan 24 '16 at 15:53
  • See [AngularJS: Creating multiple factories for every endpoint?](http://stackoverflow.com/a/17233634/5535245) – georgeawg Jan 24 '16 at 16:40
  • Possible duplicate of [AngularJS: Creating multiple factories for every endpoint?](http://stackoverflow.com/questions/17233481/angularjs-creating-multiple-factories-for-every-endpoint) – georgeawg Jan 24 '16 at 16:41

0 Answers0