本文整理匯總了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);
});