我已选择根据以下问题的已接受答案中的选项 2 创建解决方案: Unit-testing directive controllers in Angular without making controller global。
我的代码看起来像这样:
(function () {
function myCtrl($scope) {
//All my controller code.
};
myAppModule.directive('myDirective', function($compile, $timeout) {
return {
restrict: 'E',
replace: true,
controller: myCtrl,
compile: function(tElement, tAttrs, transclude) {
return {
post: function(scope, element, attrs) {
//more code and stuff.
}
}
}
});
})();
我的简单问题是;因为控制器没有定义在模块的范围内,我如何将它加载到我的测试文件中?