Controller 测试套件一(主 Controller ):
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
});
}));
接着是另一个描述和它
。这个效果很好。
第二个测试套件,用于我的模态 Controller :
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
});
}));
后跟另一个描述和一个它
。
第二个 Controller 抛出此错误:错误:[ng:areq]参数“modalController”不是函数,未定义
主 Controller 声明:
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
}]);
模态 Controller :
angular.module("app").controller("modalCtrl", ["$scope", "shareDataService", "getDataService", function ($scope, shareDataService, ngDialog, getDataService) {
//stuff
}]);
最佳答案
你好像把名字搞混了
您的 Controller 被声明为 modalCtrl
而不是您尝试在测试中使用的 modalController
关于javascript - 两个 Controller 测试套件,其中一个给出 "Error: [ng:areq] Argument ' modalController' 不是函数,未定义”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36017006/