Routeparams in Angularjs

Asked

Viewed 65 times

1

I’m using Routeparams in Angularjs

$routeProvider.when("/ReciboPagamentoCorretor/:NUMERO_RECIBO", {
    templateUrl: "view/ReciboPagamentoCorretor.html",
    controller: "ReciboPagamentoCorretorController"
})

but at the time of rootScope

 $http.get(config.BaseUrl + "/auth.php").success(function(inf) {
     if (typeof inf == "object") {
         if (inf.nivel == 1 && $location.path() != "/ContratosCorretor" &&
         $location.path() != "/NovoContratoCorretor" &&
         $location.path()!= "/PagamentosCorretor" &&
         $location.path() != "/ReciboPagamentoCorretor" &&
         $location.path() != "/ContratosPendentesCorretor") {
             $location.path("/ContratosCorretor")
         }
    }
})

He says that location.path() != "/ReciboPagamentoCorretor" is true and won’t let me access the page /ReciboPagamentoCorretor

  • 1

    But, what is your goal? I don’t know why you mentioned the use of routeParams but are only using $Location. What is your goal and what is the current problem?

  • That verification location.path() != "/ReciboPagamentoCorretor" is true, for the $location.path() that must be coming according to your route, must be something: "/ReciboPagamentoCorretor/1", where number 1 would be the :NUMERO_RECIBO of route. So this "/ReciboPagamentoCorretor/1" is different from that "/ReciboPagamentoCorretor". What you can try to do to solve this is a startWith (starts with) or some regular expression.

No answers

Browser other questions tagged

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