login with php and Angularjs

Asked

Viewed 244 times

0

I created a login form. I’m almost done authenticating and all that’s left is to be able to redirect the user to the right page.

Angularjs:

app.controller("LoginController", function ($scope, $http, $state) {

$scope.loginInfo = {
    nome: undefined,
    senha: undefined
}

$scope.loginUser = function () {
    var data = {
        nome: $scope.loginInfo.nome,
        senha: $scope.loginInfo.senha
    }

    $http.post("admin/php/login.php", data).then(function(response){
        //console.log(response);
        $state.go("admin/views/painel", response);
    }).catch(function(error){
        console.error(error);
    });
    //})
}

});

Someone knows how to do it?

  • 2

    Use $Location.path('admin/views/panel')

  • This appeared on the console: "$Location is not defined(...)"

  • 2

    Add to your controller looking like this: app.controller("Logincontroller", Function($Scope,$http,$state,$Location)

  • It worked. Thanks.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.