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

$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;
                        }
                    }
                });

 
  
 
  
 
  
 
 

你可能感兴趣的:(angularjs)