通过路由url携带参数进行参数传递
2017-12-19 15:14
706 查看
一、url解析参数
在路由中写入,同一个控制器,同一个页面模板,可以写多个路由,不同的路由对应相同的页面,只是在这种传参数的状态下的特定页面。
在模板里,再跳转的ui-sref里的写的是state的状态,增加target,新开页。
PS:1、ng-class是针对于后端返回的数值,如果数值为0,不可点击的需求。不可点击使用属性pointer-event:none。
在目的地页面控制器js里进行url解析,在初始化的时候,进行解析
PS:1、通过url中是否传了传的标志位orderStatus,函数indexof('orderStatus')>=0,表示含有这个标志位
2、split函数,对字符串进行分割,split('='),从字符串从左至右的第一个‘=’进行分割,分成数组,如果有1个‘=’就是分成两个数组,‘=’之后为一个数组,‘=’之前包括‘=’为一个数组,split('=')[1],表示取‘=’之后的数组,因为js数组初始值从0开始。
在路由中写入,同一个控制器,同一个页面模板,可以写多个路由,不同的路由对应相同的页面,只是在这种传参数的状态下的特定页面。
.state("OrderRecord", { parent: "ServiceManage", url: "/order-record", templateUrl: "partials/service/transaction/order-record.html", controller: "OrderRecordCtrl" }) .state("OrderRecordQuery", { parent: "ServiceManage", // params: {"orderStatus":null}, url: "/order-record/orderStatus/?:orderStatus/:startTime/:endTime", templateUrl: "partials/service/transaction/order-record.html", controller: "OrderRecordCtrl" })
在模板里,再跳转的ui-sref里的写的是state的状态,增加target,新开页。
<div class="link-num-mar"> <a class="link-num" ng-class="{'un-click':main.newOrdersCnt===0}" ui-sref="OrderRecordQuery({orderStatus: main.orderQueryParam.orderStatus,startTime: main.orderQueryParam.startTime,endTime:main.orderQueryParam.endTime})" target="_blank"> {{main.newOrdersCnt}} </a> </div>
PS:1、ng-class是针对于后端返回的数值,如果数值为0,不可点击的需求。不可点击使用属性pointer-event:none。
在目的地页面控制器js里进行url解析,在初始化的时候,进行解析
function init() { if($scope.url.indexOf('orderStatus')>=0){ $scope.orderParam.orderStatus = $scope.url.split('=')[1].split('&')[0]; $scope.orderParam.startTime = $scope.url.split('=')[2].split('&')[0]; $scope.orderParam.endTime = $scope.url.split('=')[3].split('&')[0]; $scope.startTime = $scope.url.split('=')[2].split('&')[0]; $scope.endTime = $scope.url.split('=')[3].split('&')[0]; // console.log($scope.orderParam.endTime); $scope.orderParam.pageSize=$scope.pageSize; $scope.orderParam.pageNumber=$scope.pageNumber; TransactionService.getAllOrderCase($scope.orderParam).then(function(result) { $scope.orderRecords = result.datas; $scope.totalCount = result.totalDataCount; $scope.totalOrder = result.totalDataCount; }); }else{ $scope.orderParam.pageSize=$scope.pageSize; $scope.orderParam.pageNumber=$scope.pageNumber; TransactionService.getAllOrderCase($scope.orderParam).then(function (result) { $scope.orderRecords = result.datas; $scope.totalCount = result.totalDataCount; $scope.totalOrder = result.totalDataCount; }); } };
PS:1、通过url中是否传了传的标志位orderStatus,函数indexof('orderStatus')>=0,表示含有这个标志位
2、split函数,对字符串进行分割,split('='),从字符串从左至右的第一个‘=’进行分割,分成数组,如果有1个‘=’就是分成两个数组,‘=’之后为一个数组,‘=’之前包括‘=’为一个数组,split('=')[1],表示取‘=’之后的数组,因为js数组初始值从0开始。
相关文章推荐
- 通过jsp的URL进行参数传递的时候出现参数为空的情况
- HttpURLConnection:访问服务器端,做登录-->get请求。参数是通过url来进行传递
- 通过URL传递中文参数导致访问失败
- 通过url地址传递多个参数
- vue中如何不通过路由直接获取url中的参数
- javascript通过url向jsp页面传递中文参数乱码解决方法
- ClickOnce 通过URL传递参数
- 备忘录:javascript通过url向jsp页面传递中文参数乱码解决方法
- javascript通过url向jsp页面传递中文参数导致乱码解决方案
- 解析:ClickOnce通过URL传递参数 XXX.application?a=1
- 关于通过URL传递中文参数的问题
- 通过注册的URL Scheme向目标APP传递参数
- ASP.net通过URL传递参数
- 如何在url地址栏中直接写数组参数进行传递
- 通过url传递参数时,如何获取全部参数
- js获取url中的参数,url中传递中文的时候通过js解码的方式
- 通过URL向报表传递参数
- perl 用参数传递URL地址进行HTML解析
- ClickOnce通过URL传递参数 XXX.application?a=1
- javascript通过url向jsp页面传递中文参数乱码解决方法