I have declared angular module in app.js like
var mainModule = angular.module('mainModule ', ["subModule"]);
var subModule = angular.module('subModule ', []);
and a JS file subController.js, that have controller defined like
subModule .controller("subController", ['$scope', '$timeout',"$rootScope", function ($scope, $timeout, $rootScope) {
...
}]);
and a HTML file subTemplate.html like
//custom directive that will load the js file with ajax call
<loadscript src="js/controllers/subController.js"></loadscript>
<div data-ng-controller="subController">
...
</div>
above code giving me error like: Error: [ng:areq] Argument 'subController' is not a function, got undefined
if I changed the controller declaration in subController.js file like below then it is working(but I dont want to declare the controller like this)
function subController($scope, $timeout, $rootScope) {
...
};
I need to implement module wise controller declaration.
Can anybody help?
Thanks.