I am trying to move angular code into separate files before the project gets too big.
I tried moving the app , controllers and services to separate files, but the errors stopped referring to points in the code (or they were too general).
I decided to put the contents of the file on a large <script> tag so that I could work with errors and make it work. Unfortunately, I came across this (Failed to instantiate protonApp module due to ...) and donโt know how to track the problem (I'm new to angular)
(function () { 'use strict'; ... }());
I have code because the (small) research I did says that you should have code between them when they are in separate files.
(function () { 'use strict'; var app = angular.module('protonApp',['ui.router','protonAppControllers','protonAppServices']); app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { ... }]); app.value('debug',true); app.run(function($rootScope,$state,$http,debug,LeftMenuService) { ... }); }()); (function () { 'use strict'; angular.module('protonAppControllers', ['$scope','$http','LeftMenuService']); }()); (function () { 'use strict'; angular.module('protonAppServices', ['$rootScope','$http']); }()); (function () { 'use strict'; angular.module('protonAppControllers').controller('loginController',['$scope','$http','$state',function($scope,$http,$state){ ... }]); }()); (function () { angular.module('protonAppControllers').controller('surveyListController',['$scope','$http','LeftMenuService',function($scope,$http,LeftMenuService){ ... }]); }()); (function () { 'use strict'; angular.module('protonAppControllers').controller('surveyHelpController',['$scope','$http','LeftMenuService',function($scope,$http,LeftMenuService){ ... }]); }()); (function () { 'use strict'; angular.module('protonAppServices').service('LeftMenuService', function($http,$rootScope){ ... }); }());
EDIT
Further digging shows that I cannot access $rootScope or $scope in any of my controller files