0

この質問に対する受け入れられた回答のオプション 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.
                }
            }
        }
    });
})();

私の簡単な質問は次のとおりです。コントローラはモジュールのスコープで定義されていないため、テスト ファイルにロードするにはどうすればよいですか?

4

1 に答える 1