anglejs 및 restangular로 재생하려고합니다.Restangular : TypeError : undefined가 함수가 아닙니다.
TypeError: undefined is not a function
at Object.login (localhost:8000/src/common/factories/session.js:110:38)
at localhost:8000/src/common/factories/session.js:207:34
at Scope.$emit (localhost:8000/vendor/angular/angular.js:12809:33)
at Scope.$scope.Login (localhost:8000/src/common/factories/session.js:185:28)
at localhost8000/vendor/angular/angular.js:10735:21
at localhost:8000/vendor/angular/angular.js:18942:17
at Scope.$eval (localhost:8000/vendor/angular/angular.js:12595:28)
at Scope.$apply (localhost:8000/vendor/angular/angular.js:12693:23)
at Scope.$delegate.__proto__.$apply (<anonymous>:855:30)
at HTMLButtonElement.<anonymous>
(로컬 호스트 : 21 8000/공급 업체/각/angular.js : 18941)
내 컨트롤러가 여기에 있습니다 : https://github.com/Seraf/LISA-WEB-Frontend/blob/master/src/common/factories/session.js#L188 및 호출 나는 그것이 나에게 오류를 줄로 restangular 사용에 문제가 로그인 기능 (위의 오류와 라인 및 라인)
위의 오류가 붙어 있기 때문에 여기서는 Restangular와 잘 작동하지 않는 것 같습니다. angularjs를 처음 접했을 때 어쩌면 최선의 방법을 사용하지 않았을 것입니다 ... 이미 루트 모듈에 대한 의존성으로 난각을 삽입했습니다 : https://github.com/Seraf/LISA-WEB-Frontend/blob/master/src/app/app.js#L6 아마도 몇 가지 문제가 발생합니까?
[EDIT] 길티 라인이다 :
110 ".setBaseUrl ('백엔드/API/V1')"
207 "$ Session.login (데이터);"
유죄 코드 : 도움을
angular.module("SessionManager", ['http-auth-interceptor','restangular'])
.constant('constSessionExpiry', 20) // in minutes
.factory("$Session", [
'$rootScope',
'$q',
'$location',
'$log',
'$http',
'constSessionExpiry',
function($rootScope, $q, $location, $log, $http, Restangular, authService, constSessionExpiry) {
return {
login: function(data){
$log.info("Preparing Login Data", data);
var $this = this;
return Restangular
.setBaseUrl('backend/api/v1')
.all('user/login/')
.post(data)
.then(function userLoginSuccess(response){
$log.info("login.post: auth-success", response);
$this.User = response;
// remove properties we don't need.
delete $this.User.route;
delete $this.User.restangularCollection;
$this.User.is_authenticated = true;
$this.cacheUser();
$this.setApiKeyAuthHeader();
$this.authSuccess();
}, function userLoginFailed(response){
$log.info('login.post: auth-failed', response);
$this.logout();
return $q.reject(response);
});
},
};
}])
감사합니다! 당신은 후자의 두 서비스에 대한 Restangular
아무것도 같은 constSessionExpiry
를 주입하고
.factory("$Session", [
'$rootScope','$q','$location','$log','$http','constSessionExpiry',
function($rootScope, $q, $location, $log, $http, Restangular, authService, constSessionExpiry) {
:
은 이러한 오류가 때 줄 번호에이 어디에 있는지 어렵다 오류가 자바 스크립트 파일과 일치하지 않는 것 같습니다. session.js의 110 번과 207 번 줄이 무슨 뜻인지 확인해 주시겠습니까? –
맞습니다. 오류 붙여 넣기 이후 수정했습니다. 죄송합니다. 110에서의 잘못된 행은 ".setBaseUrl ('backend/api/v1')" 그리고 207은 "$ Session.login (data);"입니다. 감사합니다. – Seraf
오류는 [L221] ($ https://github.com/Seraf/LISA-WEB-Frontend/blob/e25f969f0f6e9eef0b8269cb6d30ce11489855f7/src/common/factories/session.js#L221)에서'$ Session'이 정의되지 않았 음을 의미합니다. , 나는 앵글 라이브러리를 사용한 적이 없기 때문에이 시점에서 많은 도움을 줄 수는 없지만'function ($ rootScope, $ log, $ Session, $ state) {'이 호출 될 때, $ Session 매개 변수를받습니다. [L208] (https://github.com/Seraf/LISA-WEB-Frontend/blob/e25f969f0f6e9eef0b8269cb6d30ce11489855f7/src/common/factories/session.js#L208) –