3

I have 3 module names 'dashboard.services1,' , 'dashboard.services2', 'dashboard.services3' .

angular.module('dashboard.services1', [])

    .service('sublineService', function ()

that 3 services are .js (angular) files. these files i want to add in

app.js

angular.module('dashboard', ['dashboard.filters', 'dashboard.services1', 
'dashboard.services2', 'dashboard.services3', 'dashboard.directives', 
'dashboard.controllers']).
      config(['$routeProvider', function ($routeProvider, $routeParams) {
          // Dashboard Screens
          $routeProvider.when('/lines', 
{ templateUrl: 'partials/lines.html', controller: 'PlantController' });
          $routeProvider.when('/lineId/:lineId/linename/:linename', 
{ templateUrl: 'partials/line-detail.html', controller: 'LineDetailController' });
          $routeProvider.when('/subline/:lineId/:sublineId', 
{ templateUrl: 'partials/subline-detail.html', controller: 'SublineController' });
          $routeProvider.when('/equipment/:equipmentId', 
{ templateUrl: 'partials/equipment-detail.html', controller: 'EquipmentController' });
     $routeProvider.otherwise({ redirectTo: '/lines' });
      }]);

but my problem is not working all these 3 files. Last one i.e

 'dashboard.services3'

only working and getting output from these. Other 2 files were skipped. I dono want is my problem here.

My question is how to add more service files (i.e. module names ) / how to combine those module names into single .js (angular) file to get all scripts files were want to work out and get my output..

Thanks !

1 Answer 1

3

angular.module() does not take file names, it takes module names. Angular does not load scripts from the server for you, it expects the script files to have been loaded by you prior to bootstrapping the application.

You have a few options:

You would then need to load the script generated by one of these tools using a tag in your html.

Sign up to request clarification or add additional context in comments.

4 Comments

i added module names of the js file only . Not file names i.e 'dashboard.services1' ( module name) angular.module('dashboard.services1', []) .service('sublineService', function ()
yes, but angular will not load any files. There is no code in angular at all that will load any script from the server. You have to load it yourself beforehand, then angular will be able to register the module names you are passing in.
then wat shal i want to do get this... please provide samples which you know abt this to combine and load that 3 modules
Just load them with <script src="filename.js"></script> tags. Combining is not necessary unless you have a lot or want to optimize/minimize for production use. IF you do then take a look at the links in my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.