angularjs 路由传递参数 $stateParams["channel"] $routeParams

本文详细介绍了如何使用UI-Router和ng-Route为不同渠道的用户配置路由和模板加载逻辑。通过参数化的URL设置,可以灵活地根据渠道参数加载相应的页面模板。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

$stateParams

这是ui-router 

$stateParams["channel"]
     .state("weChat_teacher", {
//                url: "/wechat/:channel/:openid&?:endDate?&?:sessionId?&?:homeworkAssessmentId?&?:isReview?&?:userId?&?:userTrackingId?&?:password?&?:sessionUserTrackingId?&?:sessionName?",
               url: "/wechat/:channel/:openid?endDate&sessionId&homeworkAssessmentId&isReview&userId&userTrackingId&password&sessionUserTrackingId&sessionName",
//                 url: "/wechat/:channel/:openid?endDate",
                params: { channel: null ,openid: null,endDate: null,sessionId: null,homeworkAssessmentId: null,isReview: null,userId: null,userTrackingId: null,password: null,sessionUserTrackingId: null,sessionName: null,},
                templateUrl: function($stateParams) {
                    console.log("weChat_teacher $stateParams"+$stateParams);
                    switch ($stateParams["channel"]) {
                        case "parent":
                            url = "pages/weChat/checkHomework_patriarch.html";
                            break;
                        case "teacher":
                            url = "pages/weChat/checkHomework.html";
                            break;
                        case "homeWorkList":
                            url = "pages/weChat/checkHomework.html";
                            break;
                        case "instruction":
                            url = "pages/weChat/instructions.html";
                            break;
                        case "wechat_homework":
                        case "wechat_playlist":
                            url = "pages/weChat/redirect.html";
                            break;
                        default:
                            url = "pages/weChat/error.html";
                            break;
                    }
                    return url;
                }
            })



ng-route

 $routeParams.openid

 .when('/wechat/:channel/:openid&?:endDate?&?:sessionId?&?:homeworkAssessmentId?&?:isReview?&?:userId?&?:userTrackingId?&?:password?&?:sessionUserTrackingId?&?:sessionName?', {
                    templateUrl: function (param) { 
                        console.log("param : " + angular.toJson(param));
                        switch (param.channel) {
                           case "parent":
                                return "pages/weChat/checkHomework_patriarch.html";
                                break;
                            case "teacher":
                                return "pages/weChat/checkHomework.html";
                                break;
                            case "homeWorkList":
                                return "pages/weChat/checkHomework.html";
                                break;
                            case "instruction":
                               return "pages/weChat/instructions.html";
                                break;
                            case "wechat_homework":
                            case "wechat_playlist":
                                return "pages/weChat/redirect.html";
                                break;
                            default:
                               return "pages/weChat/error.html";
                                break;
                        }
                    }
                });





                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值