2014-09-18 3 views
3

안녕하세요 연구원 천재 개발자, 인수가 정의되지 않은있어 - AngularJS와, 카르마 테스트

은 현재 내가 AngularJS와 학습과 몇 가지 기본적인 테스트를하고 있지만 점점 오류를 계속하고있다. 제발 도와주세요. 나는 대답을 둘러 보았지만 아무 것도 찾을 수 없었다. 귀하의 모든 도움은 대단히 감사하겠습니다.

다음은 오류입니다.

`Error: [ng:areq] Argument 'controllerLogin' is not a function, got undefined 

WebStrom IDE를 사용하고 있습니다.

내 컨트롤러 로그인입니다 .js

'use strict'; 다음은

var loginApp = angular.module('loginApp',[]); 

(function() { 

    //define this for the minification of javascripts 
    var loginScope=['$scope']; 
    var loginController = function($scope){ 
     $scope.hello = "Hello Galaxy"; 

    }; 

    loginController.$inject = loginScope; 
    angular.module('loginApp').controller('loginController',loginController); 

}()); 

다음
'use strict'; 

describe("app module", function() { 

    beforeEach(module("loginApp")); 

    describe("controllerLogin", function() { 
     var scope, 
      controller; 

     beforeEach(inject(function ($rootScope, $controller) { 
      scope = $rootScope.$new(); 
      controller = $controller; 
     })); 

     it("should assign message to hello world", function() { 
      controller("controllerLogin", {$scope: scope}); 
      expect(scope.message).toBe("Hello Galaxy"); 
     }); 
    }); 
}); 

내 galaxytest.conf.js 내 loginSpec.js입니다

다음
// list of files/patterns to load in the browser 
    files: [ 
     'public/scripts/angular.js', 
     'public/scripts/angular-mocks.js', 
     'public/src/app/*.js', 
     'public/app.js', 
     '**/*.js', 
     'test/**/*Spec.js' 
    ], 

내 app.js

//Define all the module with no dependencies. 
angular.module('loginApp',[]); 


//Now Define Main Module of the Application 
var galaxyFrontendApp = angular.module('galaxyFrontendApp',['ngRoute','ui.bootstrap','loginApp']); 



galaxyFrontendApp.config(['$routeProvider', function($routeProvider) { 
    $routeProvider.when('/login', {templateUrl: 'src/app/modules/login/views/viewLogin.html', action: 'loginApp.loginController'}); 
    $routeProvider.otherwise({redirectTo: '/login'}); 
}]); 

이하 내 색인입니다 .js

<body> 
     <div ng-view></div> 



     <!-- Please refer all the javascript files here --> 
     <!-- All the JS files from scripts folder --> 
     <script src="scripts/angular.js"></script> 
     <script src="scripts/angular-route.js"></script> 
     <script src="scripts/ui-bootstrap.js"></script> 
     <script src="app.js"></script> 

     <!-- All the JS files from App folder --> 
     <!-- Module Name - login --> 
     <script src="src/app/modules/login/controllerLogin.js"></script> 
     <script src="src/app/modules/login/directiveLogin.js"></script> 




    </body> 

안내해주세요. 시간과 노력에 감사드립니다.

+0

나는이 (당신이 plnkr.co 샘플을 설정하는 경우 도움이 될) 작동하지 않는 이유는 모르지만 컨트롤러 파일의 라인'VAR loginApp = angular.module ('loginApp', []);'는 새로운 모듈을 생성하고 변수는 어디에도 사용되지 않으며 또한 주 파일은 이미이 이름을 가진 모듈을 정의합니다. – akonsu

답변

0

조치를 위해 제공된 값에 모듈 이름을 포함하지 마십시오. 모듈이 이미로드되었으며 모든 컨트롤러가 공유 네임 스페이스에 있습니다.

+0

안녕하세요 제프가 답장을 보내 주셔서 감사합니다. 문제가 아닌 것 같습니다. 여전히 같은 문제가 있습니다. 그러나 시간이 있고 나를 도울 수 있다면 당신에게 내 코드를 살펴달라고 요청할 것입니다. 코드는 GitHub (https://github.com/GeekOnGadgets/AngularGalaxyUI.git)에 있습니다. – GeekOnGadgets

3

마지막으로 나는 @DanWahlin의 도움을 얻을 수 있었고 문제를 발견했습니다. 그것은 내 galaxytest.conf.js 파일과 함께했습니다.

files: [ 
     "public/scripts/angular.js", 
     "public/scripts/angular-mocks.js", 
     "public/scripts/ui-bootstrap.js", 
     "public/scripts/angular-route.js", 
     "public/app.js", 
     "public/src/app/modules/login/controllerLogin.js", 
     "public/test/*Spec.js" 
    ], 

당신에게 개발자 감사

관련 문제