AngularJS: Routing with an URL having optional parameters

I have a url in my app.js containing routes. let's say the url is:

/api/:opt1/:opt2/:opt3/users

I want my url to work anyway, I had to ignore the optional parameters (opt1, opt2 or opt3, maybe all or several). How can i achieve this.

Is there a way that I can name $location.path('/users'), and I can also indicate which values ​​are optional parameters?

+4
source share
1 answer

Additional route parameters are marked ?, for example:

`/users/:id?`

Then this route matches both /usersand /users/1paths

+17

Source: https://habr.com/ru/post/1536213/


All Articles