aurelia-router

Aurelia JS - cannot navigate route parent with click (Route not found)?

扶醉桌前 提交于 2019-12-11 06:03:47
问题 I tried to change the contact list tutorial: http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/contact-manager-tutorial/1 ... such that it starts with a "click me" button/div, which would then load the rest of the contact list app as it was. So in order to do that, I: Copied old app.* to app-clist.* New app.* just has a <router-view> and manages the routing/navigation Added btn-start.* which just contains a div, which on click should navigate the route to app-clist . This is

Aurelia: How can I modify sidebar content from inside a router view?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 05:06:40
问题 I'm trying to wrap my head around how "inner components" can adjust the content of "outer components". Let's say I have an application template that looks something like this: <template> <div class="sidebar"> <div>Some app-wide content</div> <div> <!-- I want to put some view-specific content here --> </div> </div> <div class="main-body"> <router-view></router-view> </div> </template> Each subview wants to render different content to the sidebar. Obviously this would be easy if the subview

Aurelia router not working when resetting root

99封情书 提交于 2019-12-08 09:01:22
问题 I want to use aurelia-auth in my app and also have a login page that is completely separate from the rest of the app. I have been following the tutorial at this link: https://auth0.com/blog/2015/08/05/creating-your-first-aurelia-app-from-authentication-to-calling-an-api/ The problem I am having is after I successfully login and attempt to route to the app, none of the routes are found. I get route not found regardless of what I put in for the login redirect url. Here is my code: app.js: ...

Define a route based on the path not on the hash value

落花浮王杯 提交于 2019-12-08 07:33:06
问题 The Aurelia router maps a route the the hash . http://subdomain.hostname.tld/pathA/pathB/pathC?queryKey=queryValue#hash How can we define an Aurelia route based on the pathA/pathB/pathC value instead? 回答1: Here's an example from the docs. But in order the #hash to work you'll need to specify config.options.hashChange as false: import {Redirect, NavigationInstruction, RouterConfiguration} from 'aurelia-router'; export class App { configureRouter(config: RouterConfiguration): void { config

Redirect within MapUnknownRoutes in Aurelia

北城以北 提交于 2019-12-07 16:45:43
问题 I want bad routes to navigate to the root route. I've added a mapUnknownRoutes configuration on my router. config.mapUnknownRoutes((inst) => inst.config.moduleId = 'home'); But this leaves the route untouched. For example, #/fakeRoute routes to home. Ideally, I would like a behavior similar to returning { redirect: '#/' } , which cancels navigation and creates a new navigation to the route '#/' . Is this a feature? 回答1: The mapUnknownRoutes method also accepts a RouteConfig object so you can

Getting the current route in Aurelia

一曲冷凌霜 提交于 2019-12-06 17:15:26
问题 To get the current route within a non-view-model class, would the best practice be to inject the Router and use this.router.history.fragment? Or is this a no-no? 回答1: You could inject the router and get the current instruction. Like this: import { inject } from 'aurelia-dependency-injection'; //or framework import { Router } from 'aurelia-router'; @inject(Router) export class MyClass { constructor(router) { this.router = router; } getRoute() { return this.router.currentInstruction.config.name

Aurelia How do I use a Child Router and dynamics child routes

て烟熏妆下的殇ゞ 提交于 2019-12-06 15:38:17
Trying to use a child route in Aurelia. Can't seem to get my head around the workings of nested routes. Are all routes derived from the root of the app or relative to location of the current router? Why wont my route-href work in this example? I have a route in this router named screen and it does have an :id parameter screens/list.ts @inject(Router) export class ScreensList { heading; router; screens: any[]; constructor(router){ this.heading = 'Child Router'; this.router = router; this.screens = [ { id: 1, name: 'my screen' }, { id: 2, name: 'my other screen' } ] router.configure(config => {

Return Promise from activate() when customElements have loaded

巧了我就是萌 提交于 2019-12-06 08:53:04
问题 I know that Aurelia allows us to return a Promise() from the VM's activate() method, and if so it'll wait for the promise to resolve before switching to the new view. But, say I have a view that consists of one or several child components and they all make HTTP requests, how can I know when all children are finished from within my parent component? Bonus question: Is it correct that only VM's that go in the <router-outlet> utilize the activate() method, whereas VM's that are used as custom

Setting a “related” route as active in Aurelia

为君一笑 提交于 2019-12-06 06:14:30
问题 I have two routes in my Aurelia app, a list (Work) and a detail (WorkDetail). In the navigation, I only have the list route: Home | *Work* | Contact | . . . When I navigate to the WorkDetail view, I would like to set the Work route as active in the navigation. What I've tried so far is setting the route active in the activate() callback of the WorkDetail view and inactive on deactivate() : import {inject} from 'aurelia-framework'; import {Router} from 'aurelia-router'; @inject(Router) export

Getting the current route in Aurelia

陌路散爱 提交于 2019-12-04 22:58:42
To get the current route within a non-view-model class, would the best practice be to inject the Router and use this.router.history.fragment? Or is this a no-no? You could inject the router and get the current instruction. Like this: import { inject } from 'aurelia-dependency-injection'; //or framework import { Router } from 'aurelia-router'; @inject(Router) export class MyClass { constructor(router) { this.router = router; } getRoute() { return this.router.currentInstruction.config.name; //name of the route //return this.router.currentInstruction.config.moduleId; //moduleId of the route } }