PolymerElements / app-route

A modular client-side router

Home Page:https://www.polymer-project.org/1.0/articles/routing.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support changing the page using the data property

panuhorsmalahti opened this issue · comments

Lets say I have the following app-route defined:

    <app-route
      route="{{ route }}"
      pattern="/foo/:a/:b/:c/:d"
      data="{{ data }}">

I'd like to change the page from /bar to /foo/... using an object const o = { a, b, c, d};.

I can do this manually by calling this.set('route.path', `/foo/${o.a}/${o.b}/${o.c}/${o.d}`); - but now I'm duplicating the url definition. It would be useful to do something like this.set('data', o);, but this doesn't work since active is false when the page is /bar.

I also can't work around this by manually setting active since that's readOnly.

My workaround for now uses the internal method __getLink of app-route, maybe this could be exposed as a public method?

this.set('data', o);
this.set('route.path', this.$$('app-route').__getLink());

Cannot reproduce. I am able to simply set <app-route pattern="/:a/:b">.data = {a:'foo', b:'bar'} successfully.

Please reopen with a live code example. See our issue template for more info:
https://raw.githubusercontent.com/PolymerElements/app-route/master/.github/ISSUE_TEMPLATE.md