I am trying to inject a number of dependencies into a controller as part of a code refactoring process inline with John Papa's Style Guide. Right now, our controller looks like this:
.controller('alerting-settings.mainController', [
'$scope',
'$timeout',
'$location',
'$document',
'$window',
function($scope,
$timeout,
$location,
$document,
$window) {
According to John Papa, it should be done more like this:
/* recommended */
angular
.module('app')
.controller('DashboardController', DashboardController);
DashboardController.$inject = ['$location', '$routeParams', 'common', 'dataservice'];
function DashboardController($location, $routeParams, common, dataservice) {
}
So what happens when I refactor? I end up with this:
angular.module('app.alerting-settings')
.controller('alerting-settings.mainController', alerting-settings.mainController);
alerting-settings.mainController.$inject = [
'$scope',
'$timeout',
'$location',
'$document',
'$window'],
Problem is that I get console errors now:
What am I doing wrong?