0
我收到上面提到的錯誤,我相信這是因爲控制器沒有連接到模塊正確,但我可能是錯的。這是已經定義的控制器。AddDevicemodalCtrl不是一個函數,得到了不確定
(function() {
'use strict';
angular
.module('WS')
.controller('AddDeviceModalCtrl', AddDeviceModalCtrl);
/* @ngInject */
function AddDeviceModalCtrl(
$rootScope,
$scope,
$stateParams,
close,
Auth,
device,
DeviceAPI,
PathfinderAPI,
helpers,
GLOBAL_CONST,
Notification
) {...})();
我點擊網頁上的一個按鈕,它擊中了這個控制器,並擊中了openModal函數。 Modal對象是下面定義的服務。
(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);
}
}
})();
這裏是我的服務:
(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
}
});
}})();
,這是我的應用程序:
WS.app = angular
.module('WS', [
'interceptors',
'WS.common',
'WS.account',
'WS.layout',
'WS.dashboard',
'WS.environment',
'WS.service',
'WS.settings'
])
.config(config)
.run(run);
所以我應該放置,應用程序模塊 – DorkMonstuh
下的定義控制器的初始化是的,這是正確的! –
Sunsset,我用吞我的任務運行並連接所有文件,我可以在文件和我的所有其他控制器底部的頂部看到WS模塊但這n要似乎是問題 – DorkMonstuh