I have an AngularJS app with a single site (a map application) and a big controller where I stored all the logic. Because it was too big ( > 1000 lines of code), I decided to split it.
I made a divison in different parts, for example the creatiion of the markers, the comments on the markers, the search on them, user controll etc. and I want to create for every section a new file, but I also want them to share one single $scope.
I use the $routeProvider, where I defined one template with the old single big controller, but I don't know how to tell angular, that it should use all the new controllers I made.
I think I have an error in my reasoning building the structure. Can you tell me, how to devide the project the way I wish? Thank you very much!
More spefic: What I have:
app.controller('bigController', ['$scope',
function ($scope) {
$scope.var1;
$scope.var2;
$scope.function1 = function() {...};
$scope.function2 = function() {...};
$scope.function3 = function() {...};
$scope.function4 = function() {...};
}]);
What I want:
File 1:
app.controller('controller1', ['$scope',
function ($scope) {
$scope.var1;
$scope.function1 = function() {...};
$scope.function2 = function() {...};
}]);
File 2:
app.controller('controller2', ['$scope',
function ($scope) {
$scope.var2;
$scope.function3 = function() {...};
$scope.function4 = function() {...};
}]);
But I want access from to all $scope functions and variables in every controller and the HTML code should pick out the right function if I write
<a ng-click="function4()">example</a>
$scopes inherit from each other with prototypical inheritance, you can access properties of parent scopes from child scopes unless they're isolated.