I have build a factory to handle the functions for my controller, but somehow the controller returns an error on one of the functions:
Error: Auth.getUser(...).success is not a function @http://localhost:8080/app/controllers/mainCtrl.js:10:1
...
I have no idea what's going on here, the rest of the functions seem to be working fine?
main controller:
angular.module('mainCtrl', [])
.controller('mainController', function($rootScope, $location, Auth) {
    var vm = this;
    vm.loggedIn = Auth.isLoggedIn();
    $rootScope.$on('$routeChangeStart', function() {
        vm.loggedIn = Auth.isLoggedIn();
        Auth.getUser()
            .success(function(data) {
                vm.user = data;
            });
    });
    vm.doLogin = function() {
        Auth.login(vm.loginData.username, vm.loginData.password)
            .success(function(data) {
                $location.path('/users');
            });
    };
});
                See 'Deprecation Notice' from $http service documentation:
The $http legacy promise methods success and error have been deprecated. Use the standard then method instead.
You can learn more about these methods in the documentation about $q.
Here it is the code
Depricated code
$http(  
{  
    method: 'POST',  
    url: '/Home/CreateCustomer',   /*You URL to post*/
    data: $scope.cust   /*You data object/class to post*/
}).success(function (data, status, headers, config)  
{  
}).error(function (data, status, headers, config)  
{  
}); 
Allowed code Angular $http docs
$http(
    {
       method: 'POST',
       url: '/Home/CreateCustomer',  /*You URL to post*/
       data: $scope.cust  /*You data object/class to post*/
    }).then(function successCallback(response) {
       // this callback will be called asynchronously
       // when the response is available
    }, function errorCallback(response) {
       // called asynchronously if an error occurs
       // or server returns response with an error status.
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With