컨트롤러에서 팩토리 함수를 호출하려고합니다.Angularjs Factoryname.function이 함수가 아닙니다.
내 코드 :
angular.module("mainApp", ['ui.router', 'ngAnimate', 'toaster'])
.factory("authenticationSvc", function($http, $q, $window) {
var userInfo;
function login(userName, password) {
var deferred = $q.defer();
$http.post("/api/login", {
userName: userName,
password: password
}).then(function(result) {
userInfo = {
accessToken: result.data.access_token,
userName: result.data.userName
};
$window.sessionStorage["userInfo"] = JSON.stringify(userInfo);
deferred.resolve(userInfo);
}, function(error) {
deferred.reject(error);
});
return deferred.promise;
}
return {
login: login
};
})
.controller("LoginController", function($scope, toaster, $rootScope, $stateParams, $location, $http, authenticationSvc) {
$scope.login = authenticationSvc.login();
});
하지만 오류 여기 아래
TypeError: authenticationSvc.login is not a function
$ scope.login = ...에 중단 점을 설정 했습니까? das authenticationSvc에는 어떤 값이 있습니까? –