Search code examples
angularjsangularjs-serviceangular-fullstack

Unable to use service using last release of Angular-fullstack generator


I just updated my Angular-fullstack generator from 3.0.0-rc9 to 3.7.0.

I created a new project :

yo angular-fullstack myProject

I have some trouble when I want to create a new service :

yo angular-fullstack:service myService

Once it's created, I've got the following error on my browser : (this is my problem)

angular.js:68
Uncaught Error: [$injector:nomod] Module 'myProjectApp.myService' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

It's correctly inject in the index.html :

<script src="app/service/myService/myService.service.js"></script>

And here, the content of myService.service.js : (just in case ^^)

'use strict';

angular.module('myProjectApp.myService')
  .service('myService', function () {
    // AngularJS will instantiate a singleton by calling "new" on this function
  });

I don't know if it could comes from this : (during bower install)

Unable to find a suitable version for angular, please choose one by typing one of the numbers below:
    1) angular#~1.2.0 which resolved to 1.2.29 and is required by ngSweetAlert#1.1.0
    2) angular#~1.2.9 which resolved to 1.2.29 and is required by ng-ckeditor#0.2.1
    3) angular#>=1.4.0 which resolved to 1.5.5 and is required by angular-bootstrap#1.1.2
    4) angular#^1.2.0 which resolved to 1.5.5 and is required by ngSmoothScroll#2.0.0
    5) angular#1.5.5 which resolved to 1.5.5 and is required by angular-animate#1.5.5
    6) angular#~1.5.0 which resolved to 1.5.5 and is required by webapp2
    7) angular#^1.2.6 which resolved to 1.5.5 and is required by angular-socket-io#0.7.0
    8) angular#^1.0.8 which resolved to 1.5.5 and is required by angular-ui-router#0.2.18
    9) angular#>=1.2.0 <2.0.0 which resolved to 1.5.5 and is required by angular-validation-match#1.5.2
    10) angular#* which resolved to 1.5.5 and is required by angular-clipboard#1.4.2

Prefix the choice with ! to persist it to bower.json

? Answer 5

How to solve it ? Thanks !


Solution

  • According this, I removed .myService which give me this now :

    'use strict';
    
    angular.module('myProjectApp')
      .service('myService', function () {
        // AngularJS will instantiate a singleton by calling "new" on this function
      });
    

    It works now !