As I am restructuring my code to make it more modular, I decided to move the controller into a separate file that belongs to the same module. However, I am facing an issue where the controller does not load, even though I have verified that the load order is correct.
// app.js
angular.module("app", []);
// LoginCtrl.js
angular.module("app", []).controller("LoginCtrl", function()
{
//doSomeThing
});
I noticed that if I declare a variable 'app' in the first file using angular.module and then use the same variable in other files, everything works as expected.
// app.js
var app = angular.module("app", []);
// LoginCtrl.js
app.controller("LoginCtrl", function()
{
//doSomeThing
});
Another observation I made is that when I consolidate all the code into one file and use angular.module separately for each component, it functions properly.
// app.js
angular.module("app", []);
angular.module("app", []).controller("LoginCtrl", function()
{
//doSomeThing
});
Could there be something that I am overlooking?