サーバーからトークンを取得しようとしていますが、サービスでメソッドを呼び出すときにエラーが発生しました。コントローラ内のサービスにアクセスできない
LoginController.js:
(function(){
angular.module('app')
.controller('LoginController', [
'$http', 'authService',
LoginController
]);
function LoginController(authService) {
var vm = this;
vm.user = {};
vm.login = function() {
console.log("logging in");
authService.getToken("admin", "admin")
.then(function (data) {
console.log(data);
}, function (error) {
//TODO: error handling
})
};
}
})();
authService.js:
(function(){
'use strict';
angular
.module('app')
.factory('authService', ['$http', '$rootScope', 'REST_END_POINT',
authService
]);
function authService($http, $rootScope, REST_END_POINT){
return {
getToken: function(username, password) {
var config = {
headers: {
'Accept': 'application/json'
}
};
var data = {
username: login,
password: password
};
return $http.post(REST_END_POINT, +"/authenticate", data, config);
}
};
}
})();
私はこのエラーを取得しておいてください。
例外TypeError:authService.getTokenはLoginController.vmで機能 ではありません.login
は真剣にそれはということでしたか?ありがとう! –
あなたは大歓迎です。 ) – k10der