Apologies for this newbie question and possibly obvious answer. I have tried to break up my app into smaller files and include them at runtime using angular's module loading syntax. Thank you for your help and again apologies if this question isn't up to snuff.
The error I am getting is:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module eventBus due to:
Error: [$injector:nomod] Module 'eventBus' is not available! You either misspelled the modu...<omitted>...1)
Here is my web page:
<html>
<head>
...
</head>
<body ng-app="myApp">
<!-- Add your site or application content here -->
<div id="m" class="section app-viewport" bn-document-click="handleClick( $event )" ng-view="" ng-controller="MainController" ng-keydown="keyPress($event);"></div>
</script>
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/matchmedia/matchMedia.js"></script>
<script src="bower_components/matchmedia-ng/matchmedia-ng.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/services/eventBus.js"></script>
<script src="scripts/services/gameState.js"></script>
<script src="scripts/controllers/mainController.js"></script>
<script src="scripts/controllers/challengeControllers.js"></script>
<script src="scripts/controllers/optionControllers.js"></script>
<script src="scripts/controllers/rescueControllers.js"></script>
<script src="scripts/controllers/dayListControllers.js"></script>
<script src="scripts/controllers/bankBalanceControllers.js"></script>
<script src="scripts/controllers/canvasControllers.js"></script>
<script src="scripts/controllers/playerControllers.js"></script>
<script src="scripts/directives/layoutManagerDirectives.js"></script>
<!-- endbuild -->
</body>
</html>
And app.js:
'use strict';
var myApp = angular.module('myApp', [
'matchmedia-ng',
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute',
'eventBus',
'gameState',
// controllers
'mainController',
'challengeControllers',
'optionControllers',
'rescueControllers',
'bankBalanceControllers',
'canvasControllers',
'dayListControllers',
'playerControllers',
// directives
'layoutManagerDirectives'
// services
]);
myApp.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainController'
})
.otherwise({
redirectTo: '/'
});
});
and eventBus.js:
var myApp = angular.module('myApp');
myApp.factory("eventBus", function ($rootScope) {
var eventBus = {};
eventBus.message = '';
eventBus.prepForBroadcast = function(msg) {
this.message = msg;
this.broadcastItem(msg);
};
eventBus.broadcastItem = function(msg) {
console.log('eventBus message: ' + eventBus.message);
$rootScope.$broadcast('handleBroadcast', msg );
};
return eventBus;
});