當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Router.generate方法代碼示例

本文整理匯總了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();
 }
開發者ID:heruan,項目名稱:aurelia-security,代碼行數:24,代碼來源:authorize-step.ts

示例2:

 this.events.forEach((item:any) => {
     item.detailUrl = this.router.generate("eventDetail", {eventId: item.id});
       //console.log(item.detailUrl);
 });
開發者ID:rajajhansi,項目名稱:communityapp-aurelia-tswebpack,代碼行數:4,代碼來源:eventsList.ts


注:本文中的aurelia-router.Router.generate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。