Search code examples
generatorangular-fullstackyo

angular-fullstack:endpoint generates: unknown provider


I have used angular-fullstack:route picture and angular-fullstack:endpoint bild.

But in my route controller I want to use the Bild Schema like this:

    angular.module('galleryApp')
  .controller('PictureEditCtrl', function ($scope, $http, Auth, Bild) {

    // Use the User $resource to fetch all users
 $scope.pictures = Bild.query();
  });

But I alway get the error:

Error: [$injector:unpr] Unknown provider: BildProvider <- Bild <- PictureEditCtrl

If I replace the Bild with the initial generate User class all works very well if I use my generated class it does not.

Does someone know how to fix this ?

Thanks in advance


Solution

  • you need create a service

    yo angular-fullstack:service Bild
    

    and create a resource https://docs.angularjs.org/api/ngResource/service/$resource

    Example

    'use strict';
    
    (function() {
    
    function BildResource($resource) {
      return $resource('/api/bilds/:id/:controller', {
        id: '@_id'
      });
    }
    
    angular.module('backApp.auth')
      .factory('Bild', BildResource);
    
    })();