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

Support if="{{condition}}" in app-route #85

Open
dong77 opened this issue Feb 17, 2015 · 1 comment
Open

Support if="{{condition}}" in app-route #85

dong77 opened this issue Feb 17, 2015 · 1 comment

Comments

@dong77
Copy link

dong77 commented Feb 17, 2015

When the app needs to handle routing based on user session, it's good to have conditional app-route support so we can write someting like this:

<app-route path="/account" if="{{loggedIn}}" element="account-page"></app-route>
<app-route path="/account" if="{{!loggedIn}}" redirect="login-page"></app-route>

Currently I have to rely on a on-state-change handler, but the UX is not ideal - the router first jumpted to one page then jump back to the page I directed.

@dong77 dong77 changed the title Support if="{{condition}}"" in app-route Support if="{{condition}}" in app-route Feb 17, 2015
@erikringsmuth
Copy link
Owner

I take it you were working off of this example? https://erikringsmuth.github.io/app-router/#/events#polymer-event-mapping

The URL should really be the only conditional when routing. Otherwise you break REST. You could maybe put conditional templates in a page but that doesn't seem idea. I think the best way is to route to a separate URL like /login if the user isn't logged in. You can do a redirect or replace the current URL with router.go() https://erikringsmuth.github.io/app-router/#/api#go.

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

No branches or pull requests

2 participants