我有一个@ http://plnkr.co/edit/VnFmKqnFh0vOFARvIgVB?p=preview
(function () {
'use strict';
angular
.module('app')
.controller('MainController', MainController);
MainController.$inject = ['DataService', '$rootScope', '$scope', 'timeFilterValues', '$localStorage'];
function MainController(DataService, $rootScope, $scope, timeFilterValues, $localStorage) {
var vm = this;
vm.currentFilter = {
selections: $localStorage.getObject('currentSelections') || [],
vendors: $localStorage.getObject('currentVendors') || [],
segments: $localStorage.getObject('currentSegments') || [],
units: $localStorage.getObject('currentUnits') || [],
categories: $localStorage.getObject('currentCategories') || [],
classes: $localStorage.getObject('currentClasses') || [],
years: $localStorage.getObject('currentYears') || {},
buyers: $localStorage.getObject('currentBuyers') || [],
evp: $localStorage.getObject('currentEvp') || [],
quarters: $localStorage.getObject('currentQuarters') || [],
months: $localStorage.getObject('currentMonths') || []
};
vm.vendors = $localStorage.getObject('vendors') || [];
vm.segments = $localStorage.getObject('segments') || [];
vm.categories = $localStorage.getObject('categories') || [];
vm.units = $localStorage.getObject('units') || [];
vm.buyers = $localStorage.getObject('buyers') || [];
vm.evp = $localStorage.getObject('evp') || [];
vm.defaultSelections = $localStorage.getObject('selections') || [];
vm.years = timeFilterValues.years;
vm.quarters = timeFilterValues.quarters;
vm.months = timeFilterValues.months;
vm.filterData = new Object();
vm.filterData.vendors = $localStorage.getObject('selectedVendors') || '';
vm.filterData.segments = $localStorage.getObject('selectedSegments') || '';
vm.filterData.categories = $localStorage.getObject('selectedCategories') || '';
vm.filterData.units = $localStorage.getObject('selectedUnits') || '';
vm.filterData.buyers = $localStorage.getObject('selectedBuyers') || '';
vm.filterData.evp = $localStorage.getObject('selectedEvp') || '';
vm.filterData.date_start = $localStorage.getObject('selectedDateStart') || '';
vm.filterData.date_end = $localStorage.getObject('selectedDataEnd') || '';
vm.filterData.route = $localStorage.getObject('selectedRoute') || '';
vm.filterData.currentToggle = $localStorage.getObject('currentToggle') || 'segments';
vm.filterData.crossToggle = $localStorage.getObject('crossToggle') || 'evp';
vm.filterData.years = $localStorage.getObject('selectedYears') || '';
vm.filterData.quarters = $localStorage.getObject('selectedQuarters') || '';
vm.filterData.months = $localStorage.getObject('selectedMonths') || '';
vm.filterData.subroute = undefined;
}
})();
其中一个控制器已被定义并进一步使用,但我一直在寻找这个控制器,它给出了这个错误
错误:[ng:areq]参数'MainController'不是函数,未定义 http://errors.angularjs.org/1.4.4/ng/areq?p0=MainController&p1=not%20a%20function%2C%20got%20undefined 在REGEX_STRING_REGEXP(angular.js:68) 在assertArg(angular.js:1795) 在assertArgFn(angular.js:1805) at angular.js:9069 at setupControllers(angular.js:8133) at nodeLinkFn(angular.js:8173) 在compositeLinkFn(angular.js:7637) 在compositeLinkFn(angular.js:7641) at publicLinkFn(angular.js:7512) 在angular.js:1660为错误
答案 0 :(得分:0)
我相信这是你的d3.js
。
您已在script.js
中定义了自己的应用及其依赖关系,但在d3.js
中,您在访问模块时添加了空数组,删除此问题可解决问题
所以在d3.js
来自
angular.module('app', [])
.factory('d3Service'...
到
angular.module('app')
.factory('d3Service'...
我认为angular认为您正在重新定义您的应用程序。由于主控制器是在d3.js
之前定义的,我假设角度删除它,然后ng-controller指令正在寻找那些不存在的东西。