Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui-sref-active doesn't work with query parameters #1513

Closed
felquis opened this issue Nov 4, 2014 · 5 comments
Closed

ui-sref-active doesn't work with query parameters #1513

felquis opened this issue Nov 4, 2014 · 5 comments
Assignees
Labels
Milestone

Comments

@felquis
Copy link

felquis commented Nov 4, 2014

I'm using ui-router 0.2.10, and I'm trying to use ui-sref-active with query parameters. My state is like this:

.state('profile', {
            url: '/profile/:userName?backbutton',
            views: {
                'app-view': {
                    templateUrl: 'templates/profile/profile.html',
                    controller: 'PerfilCtrl'
                }
            }
        })

My markup is:

<a class="menu-item" ui-sref="profile({ userName: me.username, backbutton: true })" ui-sref-active="active">Yo</a>

But, when I'm in http://localhost/profile/name?backbutton=true the ui-sref-active isn't activated.

@christopherthielen
Copy link
Contributor

Can you put this in a plunkr please?
http://bit.ly/UIR-Plunk

@felquis
Copy link
Author

felquis commented Nov 17, 2014

sorry @christopherthielen, I haven't saw it in time to make a plunkr.

@PauliJP
Copy link

PauliJP commented Jan 18, 2018

I wonder why this issue is closed since its very much active bug. I'm using "0.2.15" but also tried with version "1.0.3". So, having a query parameter in the route will confuse ui-sref-active directive which won't trigger. Quite annoying since I have to add the class manually each time.

@christopherthielen
Copy link
Contributor

It’s closed because no method was posted to reproduce the error. Would you like to do so?

@PauliJP
Copy link

PauliJP commented Jan 22, 2018

I don't have standalone working example but here is pretty much it.

// Controller 1:
this.$state.go('app.workingSites.inventoryStatusesStorageAmounts.harvestingAreaPlots', {
previousUrl: '/workingSites/inventoryStatuses/storageAmounts'
});

// Controller 2:
@route([
{
name: 'app.workingSites.inventoryStatusesStorageAmounts.harvestingAreaPlots',
url: '/plots?:previousUrl',
...
}, ...
]

// Template 2:

        <div class="nav-container">
            <a class="nav-item" ui-sref={{haDetails.plotsPath}} ui-sref-active="current">myTab</a>
...
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants