Angular parameters not required on the route

1

I have a screen where I need to pass a parameter according to your call, that is, you have calls that do not need to pass the parameter and have calls that are direct queries that need to pass the parameter.

My question is how do I not want to pass the parameter (parameter is integer type, where I am passing 0 (zero)) so that it does not have the url and the value zeroed. example:

No parameter:

 http://localhost:9080/sc/#/logistica/requisicoes/0

With parameter:

http://localhost:9080/sc/#/logistica/requisicoes/2000936

My route:

.state('app.logistica.requisicoes', {
                    url: '/requisicoes/:id',
                    templateUrl: 'views/logistica-requisicoes.html',

I would like my URL when the parameter was not needed to be without zero.

http://localhost:9080/sc/#/logistica/requisicoes
    
asked by anonymous 27.07.2017 / 02:49

1 answer

1

The default for an optional parameter is to add at the end the sign for ? , example:

.state('app.logistica.requisicoes', {
                    url: '/requisicoes/:id?',
                    templateUrl: 'views/logistica-requisicoes.html',

27.07.2017 / 03:30