christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
915 stars 211 forks source link

Exact url match instead of everything that follows #361

Closed harm-less closed 7 years ago

harm-less commented 7 years ago

Hello,

I'm not sure if it's a bug, a missing feature or me not knowing what to do exactly. I couldn't find it in the documentation so far.

I'm trying to setup some future states including a homepage. This is just a hypothetical setup:

{
    name: 'home',
    url: '/',
    type: 'ngload',
    src: 'scripts/pages/home.js'
},
{
    name: 'other-page',
    url: '/other-page',
    type: 'ngload',
    src: 'scripts/pages/other-page.js'
}

When I navigate to the "home" page the home.js file gets loaded fine. The problem occurs when I enter another page (which of course always starts with a /) both the home.js and other-page.js are loaded. I guess it's expected because the home's future state url will become /.*. How can I set the url matcher to an exact match? So how can I make sure home.js does not load when it's not on the "home" page?

Thanks!

P.s.: Setting the url to /home is not an option.

harm-less commented 7 years ago

Rookie mistake, the route just had to be registered last so other routes take priority over the the "home" state