Exchanging from partial to script without reloading the Angular application

0

Hello, I was doing some tests. And if I want to do a conditional for a single button, I can send it to a Partial passing a parameter, or not. And I made a button calling this function: Controller

$scope.continuar = function(){
    $http.get('http://localhost:8080/api/getbyemail/[email protected]')
        .success(function(retorno) {
            console.log(retorno);
            $scope.infos = retorno;
            if (retorno.usuarioId){
                console.log("Vai passar COM o parametro");
                window.location.href = "pagina/usuarioId";
            } else {
                console.log("Vai passar SEM o parametro");
                window.location.href = "pagina";
            }
        })
        .error(function(erro) {
            console.log(erro);
        });
    };

It worked, it went, BUT, it reloaded my application, and my intention is to actually use the SPA, both partials are part of the same application. I did not want to recharge it.

Is there any way to do this?

Thank you.

    
asked by anonymous 04.08.2016 / 19:14

1 answer

0

I was able to find the answer:)

instead of using the javascript code

 window.location.href = "pagina/usuarioId";

Now I use:

$location.path("pagina/" + usuarioId);

and it just changes the view:)

    
04.08.2016 / 20:57