本文整理汇总了TypeScript中aurelia-router.Router.generate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Router.generate方法的具体用法?TypeScript Router.generate怎么用?TypeScript Router.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-router.Router
的用法示例。
在下文中一共展示了Router.generate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
run(currentInstruction: NavigationInstruction, next: Function): Promise<any> {
for (let instruction of currentInstruction.getAllInstructions()) {
if (instruction.config.settings.requireAuthentication || instruction.config.settings.hasOwnProperty("roles")) {
if (this.securityContext.getUserPrincipal() == null) {
throw new Redirect(this.router.generate(this.securityContext.configuration.signInRoute, {
// message: this.i18n.tr("security:unauthorized", {
// defaultValue: "You are not authenticated, please sign-in."
// }),
message: "You are not authenticated, please sign-in.",
path: currentInstruction.fragment
}));
} else if (Array.isArray(instruction.config.settings.roles) && !instruction.config.settings.roles.some((role: string) => this.securityContext.isUserInRole(role))) {
throw new Redirect(this.router.generate(this.securityContext.configuration.forbiddenRoute, {
// message: this.i18n.tr("security:forbidden", {
// defaultValue: "You are not authorized to access this resource."
// }),
message: "You are not authorized to access this resource",
path: currentInstruction.fragment
}));
}
}
}
return next();
}
示例2:
this.events.forEach((item:any) => {
item.detailUrl = this.router.generate("eventDetail", {eventId: item.id});
//console.log(item.detailUrl);
});