MyApp.js:
'use strict';
angular.module('MyApp', [
'ngRoute',
'MyApp.components.hello',
'MyApp.pages.index',
'MyApp.pages.upload'
]).
config(['$routeProvider', 'HelloService', function($routeProvider, HelloService) {
$routeProvider.
when('/',
{
templateUrl: 'pages/index/index.html',
controller: 'IndexController'
}).
when('/upload',
{
templateUrl: 'pages/upload/upload.html',
controller: 'UploadController'
}).
otherwise({redirectTo: '/'});
HelloService.init({
facebook : ID_HERE
});
}]);
hello-service.js:
'use strict';
angular.module("MyApp.components.hello", []).
factory("HelloService", function()
{
return window.hello; //assume hello has been loaded
});
When I try to run it, I get the error Error: [$injector:unpr] Unknown provider: HelloService
. Why? HelloService is clearly defined in MyApp.components.hello, which is included as a dependency of the main application. So why can't it find HelloService?