angular js路由传参
从A页面跳转到B页面:
$scope.goToDetail = function(excelId){ var data = angular.copy( $stateParams, {});//拷贝本页面(A页面)url上的所参数 data.excelId = excelId; //本页所得 $state.go('exam.importDetail',data);//将本页面(A页面)url上的所有参数传到将要跳转到的页面(B页面) };
//A页面路由配置
//考点导入 .state('exam.import',{ url:'/site/:examPrjId/:orgId/:orgType/import', controller:'ExamSiteImportController', templateUrl: 'exam/site/import/examSiteImport.html', resolve: { loadService: ['$ocLazyLoad', function ($ocLazyLoad) { return $ocLazyLoad.load(['ExamSiteAgentModule',{ files: [ 'exam/site/import/controller.js' ] }]); }], examSite: ['$stateParams', 'examSiteImportListService', '$window', 'loadService', function($stateParams, examSiteImportListService, $window){ var orgId = $window.localStorage.getItem("orgId"); var orgType = $window.localStorage.getItem("orgType"); return examSiteImportListService({examId: $stateParams.examPrjId,orgId:orgId, orgType:orgType,pageNum: 1, size:10}); }] } })
//B页面路由配置
//导入明细 .state('exam.importDetail',{ url:'/site/:examPrjId/:orgId/:orgType/import/detail/:excelId', controller:'importDetailController', templateUrl:'exam/site/import/importDetail/importDetail.html', resolve: { loadService: ['$ocLazyLoad', function($ocLazyLoad){ return $ocLazyLoad.load(['ExamSiteAgentModule', { files: [ 'exam/site/import/importDetail/improtDetailController.js' ] }]); }], importDetailList:['getExamSiteImportItemListService', '$stateParams', '$window','loadService',function(getExamSiteImportItemListService, $stateParams,$window){ var orgId = $window.localStorage.getItem("orgId"); var orgType = $window.localStorage.getItem("orgType"); return getExamSiteImportItemListService({excelId:$stateParams.excelId,pageNum:1, size:10}) }], examSiteImportItemCount:['getExamSiteImportExcelItemCountService', '$stateParams', '$window', 'loadService',function(getExamSiteImportExcelItemCountService, $stateParams,$window){ var orgId = $window.localStorage.getItem("orgId"); var orgType = $window.localStorage.getItem("orgType"); return getExamSiteImportExcelItemCountService({excelId:$stateParams.excelId}) }] } })
//agent和后台接口
//考点导入信息 function examSiteImportAgent($resource, $Configuration){ return $resource($Configuration.eduExamSiteImportContext + /*"/examsiteexcel" + */"/edu/exam/examsite/excel/:excelId", {excelId: '@excelId'}); } //获取导入考点状态 function examSiteImportService($q, examSiteAgent){ return function(param){ var delay = $q.defer(); examSiteAgent.get(param, function (result) { delay.resolve(result); }, function (message) { delay.reject(message); }); return delay.promise; }; }// edu/exam/examsite/excel/:excelId" , { excelId : '@excelId' } 后台请求传递参数格式
//上传文件 插件upload格式
Upload.upload({ url: $Configuration.eduExamScopeContext + "/edu/exam/examsite/excel", data: { examId: $stateParams.examId, userId: securityContent.getUserId(), orgId: orgId, orgType: orgType }, file: $scope.file }).then(function (result) { excelId = result.data.excelId; intervalKey = IntervalFactory.interval(checkExamSiteImportExcel, 3000, 0, commandId) }, function (error) { });
$scope.$watch('file',function(){ $scope.showFaileReason = null; });
//监控值改变时调用的function