Reputation: 356
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 !
Upvotes: 3
Views: 6557
Reputation: 13681
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:
Use a third-party tool to combine all your javascript files into one file and optionally minimize/optimize. You can use things such as:
You would then need to load the script generated by one of these tools using a tag in your html.
Upvotes: 3