2014-09-28 3 views
1

MY 컨트롤러의 주요오류 : 오류 : unpr 알 수없는 제공자

var MyApp = angular.module('ionicApp', ['ionic', 'MobiNav', 'authFactory']); 

CONTROLLER 소비 활동 FACTORY

MyApp.controller('AuthUser', ['$scope', 'authFactoryService', function ($scope, authFactoryService) { 
    $scope.showForm = true; 
    $scope.UserDataLogin = function() { 
     var loginData = {}; 
     $scope.registration = { 
      userName: $scope.Auth.userName, 
      password: $scope.Auth.password, 
      confirmPassword: $scope.Auth.password 
     }; 
     authFactoryService.SaveRegistration(registration); 
     window.scope = loginData; 
    }; 
} 
] 
); 

이 별도의 파일에있는 공장을 내가지고있어 무엇

var AuthService = angular.module('authFactory', []); 
AuthService.factory('authFactoryService', [ 
    '$http', '$q', '$scope', function ($http, $q, $scope) { 
    return { 
     SaveRegistration: function() { 
      var urlBase = 'http://localhost:48868/'; 
      $http.post(urlBase + 'api/account/register', registration).then(function(response) { 
        $scope.savedSuccessfully = true; 
        $scope.message = "User has been registered successfully, you will be redicted to login page in 2 seconds."; 
       }, 
       function(response) { 
        var errors = []; 
        for (var key in response.data.modelState) { 
         for (var i = 0; i < response.data.modelState[key].length; i++) { 
          errors.push(response.data.modelState[key][i]); 
         } 
        } 
        $scope.message = "Failed to register user due to:" + errors.join(' '); 
       }); 
     } 

    }; 
}]); 

오류 오류 : [$ injector : unpr] http://errors.angularjs.org/1.2.17/ $ injector/unpr? p0 = copeProvider % 20 % 3C- % 20 % (기본) 오류에서 24scope % 20 % 3C- %의 20authFactoryService 이

가없는 이유

authFactoryService 서비스

답변

3

는 파고가 $ 범위 다시 공장 에 주입 마지막 체격 대체이이

AuthService.factory('authFactoryService', [ 
    '$http', '$q', '$scope', function ($http, $q, $scope) {}]); 

(단지 다시 주입 하였다 $ 범위 삭제 의존성을위한 공장

AuthService.factory('authFactoryService', [ 
     '$http', '$q', function ($http, $q, $scope) {}]); 
1

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

를로드하는 당신은 당신의 모듈에 하늘의 배열을 indlcuded. 이렇게하면 모듈 설정자가 기존 모듈을 덮어 씁니다. angular.module ('authFactory')을 사용하는 모듈을 가져 오려면 < - 누락 된 두 번째 매개 변수를 기록하십시오.

안부 샌더

+0

i 위와 같이 시도했습니다. 아래 오류 메시지가 나타납니다. 잡히지 않은 오류 : [$ injector : nomod] http://errors.angularjs.org/1.2.17/$injector/nomod?p0=authFactory –

관련 문제