[AngularJS][ui-router]: optional params in states in the middle of URL

Stepan Suvorov

I would like to have something like:

  .state('courses', {
    url: '/{?type}/courses',
  })

to make "type" optional.

We've found this solution:

  .state('courses', {
    url: '{type:(?:/[^/]+)?}/courses',
  })

BUT

When you enter you app directly by link you will get extra slash with type param.

Sergiy Pereverziev
.state('courses', {
  url: '/:type/courses',
  params: {
    courses: {
      value: 'defaultType',
      squash: true
    }
  }
})

Thanks to a genius who suggested https://github.com/angular-ui/ui-router/issues/1501

Gosh, spent almost half of the day on that feature

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

"optional" params in AngularJS states/views with ui-router

From Dev

AngularJS UI-Router optional url segment in the middle

From Dev

React Router - Route With Optional Params Not Working

From Dev

AngularUI Router: multiple states with same url pattern

From Dev

Angular UI Router: Different states with same URL?

From Dev

URL Routing for nested states in ui-router

From Dev

Angular js - optional dynamic url params

From Dev

Angular js - optional dynamic url params

From Dev

AngularJS ui-router: URL with params and without params

From Dev

Keep URL params ui-router

From Dev

React router url params not stored in props

From Dev

Issue with URL params in react-router

From Java

AngularJS ui router passing data between states without URL

From Dev

AngularJS ui-router default state for states without a URL

From Dev

angular ui-router, how to nest states with a url that updates

From Dev

Angular UI-router - keep url param across more states

From Dev

angular ui-router, how to nest states with a url that updates

From Dev

Angular Typescript send optional restful url params only if they are not empty

From Dev

Passing two params on angular js url using app states js and view

From Java

How to set URL query params in Vue with Vue-Router

From Dev

Get url params inside a Redux middleware using React-router

From Dev

Angular UI Router doesn't get query params on url change

From Dev

How to access URL params in v-router beforeEach block?

From Dev

Iron Router OnBefore Hook with Params URL Not Calling Function

From Dev

Unable to pull :page params from the URL on 301 router redirect

From Dev

Apply angular filter on ui-router url params

From Dev

Angular ui-router params if specific child-url

From Dev

Optional parameter in the middle of a route

From Java

Constructor Optional Params

Related Related

  1. 1

    "optional" params in AngularJS states/views with ui-router

  2. 2

    AngularJS UI-Router optional url segment in the middle

  3. 3

    React Router - Route With Optional Params Not Working

  4. 4

    AngularUI Router: multiple states with same url pattern

  5. 5

    Angular UI Router: Different states with same URL?

  6. 6

    URL Routing for nested states in ui-router

  7. 7

    Angular js - optional dynamic url params

  8. 8

    Angular js - optional dynamic url params

  9. 9

    AngularJS ui-router: URL with params and without params

  10. 10

    Keep URL params ui-router

  11. 11

    React router url params not stored in props

  12. 12

    Issue with URL params in react-router

  13. 13

    AngularJS ui router passing data between states without URL

  14. 14

    AngularJS ui-router default state for states without a URL

  15. 15

    angular ui-router, how to nest states with a url that updates

  16. 16

    Angular UI-router - keep url param across more states

  17. 17

    angular ui-router, how to nest states with a url that updates

  18. 18

    Angular Typescript send optional restful url params only if they are not empty

  19. 19

    Passing two params on angular js url using app states js and view

  20. 20

    How to set URL query params in Vue with Vue-Router

  21. 21

    Get url params inside a Redux middleware using React-router

  22. 22

    Angular UI Router doesn't get query params on url change

  23. 23

    How to access URL params in v-router beforeEach block?

  24. 24

    Iron Router OnBefore Hook with Params URL Not Calling Function

  25. 25

    Unable to pull :page params from the URL on 301 router redirect

  26. 26

    Apply angular filter on ui-router url params

  27. 27

    Angular ui-router params if specific child-url

  28. 28

    Optional parameter in the middle of a route

  29. 29

    Constructor Optional Params

HotTag

Archive