admin管理员组文章数量:1345579
I have a router.js file with my configured routes:
routes.js
export class App {
configureRouter(config, router) {
config.title = 'Aurelia';
config.map([
{route: ['', `wele`], name: 'wele', moduleId: './wele', nav: true, title:'Wele'},
{route: 'http', name: 'http', moduleId: './http', nav: true, title:'HTTPTest'},
{route: 'users', name: 'users', moduleId: './users', nav: true, title:'Github Users'},
{route: 'plan', name: 'plan', moduleId:'./dp/plan', nav: true, title:'DPTest'},
{route: 'user_table', name: 'user_table', moduleId:'./dp/user_table', nav: true, title:'Benutzer'}
]);
this.router = router;
}
}
I want to call one of these routes (plan
) from a function in users.js
. Do I have to import {Router} in users.js? Or inject?
I have a router.js file with my configured routes:
routes.js
export class App {
configureRouter(config, router) {
config.title = 'Aurelia';
config.map([
{route: ['', `wele`], name: 'wele', moduleId: './wele', nav: true, title:'Wele'},
{route: 'http', name: 'http', moduleId: './http', nav: true, title:'HTTPTest'},
{route: 'users', name: 'users', moduleId: './users', nav: true, title:'Github Users'},
{route: 'plan', name: 'plan', moduleId:'./dp/plan', nav: true, title:'DPTest'},
{route: 'user_table', name: 'user_table', moduleId:'./dp/user_table', nav: true, title:'Benutzer'}
]);
this.router = router;
}
}
I want to call one of these routes (plan
) from a function in users.js
. Do I have to import {Router} in users.js? Or inject?
- please upvote and accept if this helped you – Matthew James Davis Commented Jul 28, 2016 at 15:26
1 Answer
Reset to default 13Either of the following will work
using router.navigateToRoute()
import { Router } from 'aurelia-router';
@inject(Router)
export class UsersViewModel {
constructor(router) {
this.router = router;
}
doStuff() {
this.router.navigateToRoute('plan');
}
}
using native location
export class UsersViewModel {
doStuff() {
location.assign('#/users');
}
}
本文标签: javascriptAureliaio how to navigate to routeStack Overflow
版权声明:本文标题:javascript - Aurelia.io: how to navigate to route - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743795434a2540341.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论