javascript - How do I get the current route in an Aurelia html template? -
i have aurelia application page has 2 routes pointing @ -- is, 'create-password' , 'reset-password' both point reset-password.html. reset-password.js file injects router, view-model can access router.
i want able change items in page based on route used access page. how current route displaying page?
i'm thinking ${router.currentroute} should work?
the best come with, after inspecting router object, current fragment history property. in reset-password.js:
iscreateroute() { return this.router.history.fragment == '/create-password' } then in reset-password.html:
<div if.bind="iscreateroute()">create</div> <div if.bind="!iscreateroute()">reset</div> that's approach took getting dynamic items in page based on route.
Comments
Post a Comment