Two controller test suites, one giving " Error: [ng:areq] Argument 'modalController' is not a function, got undefined"
Two controller test suites, one giving " Error: [ng:areq] Argument 'modalController' is not a function, got undefined"
控制器测试套件一(主控制器):
describe("RTL cache viewing utility main controller test suite", function () {
var $rootScope, mainCtrl;
beforeEach(module('app'));
beforeEach(inject(function ($controller, $rootScope, $compile, $q) {
mainScope = $rootScope.$new();
ctrl = $controller('mainCtrl', {
$scope: mainScope
});
}));
之后是另一个描述和 it
s。这个很好用。
第二个测试套件,用于我的模态控制器:
describe("RTL cache viewing utility modal controller test suite", function () {
var $rootScope, modalController;
beforeEach(module('app'));
beforeEach(inject(function ($controller, $rootScope, $compile) {
mainScope = $rootScope.$new();
ctrl = $controller('modalController', {
$scope: mainScope
});
}));
接着是另一个描述和一个 it
。
第二个控制器抛出此错误:Error: [ng:areq] Argument 'modalController' is not a function, got undefined
主控制器声明:
var app = angular.module("app", ["agGrid", "ui.bootstrap"]);
angular.module("app").controller("mainCtrl", ["$scope", "$timeout", "dateFilter", "$http", "shareDataService", "getDataService", "$q", function ($scope, $timeout, dateFilter, $http, shareDataService, getDataService, $q) {
//stuff
}]);
模态控制器:
angular.module("app").controller("modalCtrl", ["$scope", "shareDataService", "getDataService", function ($scope, shareDataService, ngDialog, getDataService) {
//stuff
}]);
你好像把名字弄错了
您的控制器被声明为 modalCtrl
而不是您尝试在测试中使用的 modalController
控制器测试套件一(主控制器):
describe("RTL cache viewing utility main controller test suite", function () {
var $rootScope, mainCtrl;
beforeEach(module('app'));
beforeEach(inject(function ($controller, $rootScope, $compile, $q) {
mainScope = $rootScope.$new();
ctrl = $controller('mainCtrl', {
$scope: mainScope
});
}));
之后是另一个描述和 it
s。这个很好用。
第二个测试套件,用于我的模态控制器:
describe("RTL cache viewing utility modal controller test suite", function () {
var $rootScope, modalController;
beforeEach(module('app'));
beforeEach(inject(function ($controller, $rootScope, $compile) {
mainScope = $rootScope.$new();
ctrl = $controller('modalController', {
$scope: mainScope
});
}));
接着是另一个描述和一个 it
。
第二个控制器抛出此错误:Error: [ng:areq] Argument 'modalController' is not a function, got undefined
主控制器声明:
var app = angular.module("app", ["agGrid", "ui.bootstrap"]);
angular.module("app").controller("mainCtrl", ["$scope", "$timeout", "dateFilter", "$http", "shareDataService", "getDataService", "$q", function ($scope, $timeout, dateFilter, $http, shareDataService, getDataService, $q) {
//stuff
}]);
模态控制器:
angular.module("app").controller("modalCtrl", ["$scope", "shareDataService", "getDataService", function ($scope, shareDataService, ngDialog, getDataService) {
//stuff
}]);
你好像把名字弄错了
您的控制器被声明为 modalCtrl
而不是您尝试在测试中使用的 modalController