Angularjs错误不是一个函数

时间:2018-01-24 17:30:23

标签: angularjs

请帮助我为什么我要登录_Fac.GetData不是函数/

app.controller('LoginCtrls', function ($scope, Login_Fac, $window) {
    $scope.GetToken = function () {
            Login_Fac.GetData().then(function (d) {
                alert('success...')
            }).catch(function () {
                alert('error...')
            })

factory.js

app.factory('Login_Fac', function ($http, $window) {
    var LoginScredential = {};
 LoginScredential.GetData = function () {
         return $http({
             url: 'http://localhost:63252/api/department',
         })

1 个答案:

答案 0 :(得分:0)

将工厂更改为,

factories.factory('Login_Fac', function ($http, $window) {
    var LoginScredential = {
        GetData: () => {
            return $http({
                url: 'http://localhost:63252/api/department',
            })
        },
    };

    return LoginScredential;
});