0

.controller('LoginCtrl', function($scope, $location, $stateParams, $ionicHistory, $http, $state, $auth,$rootScope) {

    $scope.loginForm = {}
    $scope.loginError = false;
    $scope.loginErrorText;

    $scope.login = function() {

        var credentials = {
            email: $scope.loginForm.email,
            password: $scope.loginForm.password
        }

        console.log(credentials);

        $auth.login(credentials).then(function() {

            $http.get('http://localhost:8000/api/authenticate/user').success(function(response){

                var user = JSON.stringify(response.user);


                localStorage.setItem('user', user);


                $rootScope.currentUser = response.user;


                $ionicHistory.nextViewOptions({
                  disableBack: true
                });

                $state.go('app.jokes');
            })
            .error(function(){
                $scope.loginError = true;
                $scope.loginErrorText = error.data.error;
                console.log($scope.loginErrorText);
            })
        });
    }

}); I am getting this error Error: [$injector:unpr] Unknown provider: $authProvider <- $auth <- LoginCtrl when i add $auth in the function.

  • Are you adding the module to your app? You added the service to your controller, but I don't see if you added the module to your app: `satellizer` – Ariel Mar 02 '16 at 13:25
  • yeah i have added that and i used both satellizer CDN and also the downloaded file in index.html but still it's forking this error.. – Kaushik Mishra Mar 02 '16 at 13:29
  • `angular.module('YourApp', [ 'ionic', 'satellizer' ]);` this is how you define your app? That's what I meant, add the module as a dependency of your app. – Ariel Mar 02 '16 at 13:39
  • yeah i solved that error but now it's showing this error POST http://localhost:8100/auth/login 404 (Not Found) i don't know how is this invoked – Kaushik Mishra Mar 02 '16 at 14:12
  • Did my comment help you solve your problem? Please post an answer explaining how you solved your problem, now if you have another question you should ask that question in a new thread :) – Ariel Mar 02 '16 at 14:25
  • Yeah i solved that problem thanks... – Kaushik Mishra Mar 02 '16 at 14:40
  • Then please add an answer explaining how you fix it so others can see it as well (: – Ariel Mar 02 '16 at 14:43

0 Answers0