I am encountering the error mentioned above, I suspect that it is due to the controller not being properly attached to the module. However, I could be mistaken. Below is the definition of the controller.
(function () {
'use strict';
angular
.module('WS')
.controller('AddDeviceModalCtrl', AddDeviceModalCtrl);
/* @ngInject */
function AddDeviceModalCtrl(
$rootScope,
$scope,
$stateParams,
close,
Auth,
device,
DeviceAPI,
PathfinderAPI,
helpers,
GLOBAL_CONST,
Notification
) {...})();
When I click a button on the webpage, it triggers this controller and executes the openModal function. The Modal object is a service defined as follows.
(function() {
'use strict';
angular
.module('WS.environment')
.controller('DevicesCtrl', DevicesCtrl);
/* @ngInject */
function DevicesCtrl($rootScope, $scope, $state, $stateParams, DeviceAPI, helpers, GLOBAL_CONST, Modal) {
angular.extend($scope, {
openModal: openModal,
editDevice: editDevice
});
angular.extend($scope, {
devices: [],
errors: []
});
$rootScope.$on('deviceAdded', onUpdateDeviceList);
DeviceAPI
.getDevices()
.then(onGetDeviceListSuccess);
function onGetDeviceListSuccess(devices) {
$scope.devices = devices;
}
$rootScope.$on('updateDevicesEvent', function(event, devices) {
onGetDeviceListSuccess(devices);
});
function openModal($event) {
Modal.showAddDevice($scope.device);
}
function editDevice($event, device) {
Modal.showEditDevice(device);
}
function onUpdateDeviceList($event, device) {
$scope.devices.push(device.device);
}
}
})();
Below is my service definition.
(function() {
'use strict';
angular
.module('WS.service')
.factory('Modal', Modal);
/* @ngInject */
function Modal($rootScope, ModalService) {
var service = {
showAddDevice: showAddDevice,
showEditDevice: showEditDevice,
showConfirmation: showConfirmation,
showTimeRange: showTimeRange
};
return service;
function showAddDevice(device) {
$rootScope.modalHasOpen = true;
return ModalService.showModal({
templateUrl: 'modules/modals/device/add/views/device.html',
controller: 'AddDeviceModalCtrl',
inputs: {
device: device
}
});
}})();
Lastly, here is my app configuration.
WS.app = angular
.module('WS', [
'interceptors',
'WS.common',
'WS.account',
'WS.layout',
'WS.dashboard',
'WS.environment',
'WS.service',
'WS.settings'
])
.config(config)
.run(run);