Struggling to create a basic angular application, every time I attempt it, I encounter this issue and can never find a solution.
The content of App.js is as follows:
angular.module('Euclid',
['ui.bootstrap',
'ngRoute'])
.controller('mainController', function($scope){
})
.config(['$routeProvider', function($routeProvider){
$routeProvider.
when('/', {
templateUrl: 'views/home.html',
controller: 'HomeController',
controllerAs: 'homeCtrl'
});
}]);
Just a simple routing setup with nothing in the controller.
The 'HomeController' code looks like this:
var HomeController = function($scope){
var self = this;
// code here
};
angular.module('Euclid').controller('HomeController', HomeController);
My index.html file is structured as below:
<html lang="en" ng-app="Euclid">
<body ng-controller="mainController" ng-cloak>
<script src="node_modules/angular/angular.js"></script>
<script src="app.js"></script>
<div class="container">
<div ng-view></div>
</div>
</body>
</html>
The error message displayed is "Argument 'HomeController' is not a function, got undefined". It's puzzling trying to figure out where the function is going undefined.