我正在使用 Angular.Js 并使用工厂加载我的数据,我遇到了我的请求重复的问题。我正在注入另一个名为 filter 模块的模块。
我的搜索模块
var searchjob = angular.module('searchjobs', ['infinite-scroll', '720kb.socialshare', 'ui.bootstrap', 'rzSlider','ngclipboard', 'filtermodule']);
searchjob.controller('jobListController', function jobListController($scope, $http, Session, baseurl, $window, job_service, search_service, $location) {
$scope.getJobList = function(page) {
$scope.showLoader = 1;
if (typeof(page) == "undefined") {
page = 0;
}
$scope.page = page + 1;
job_service.getJobList($scope.page).then(function(ls) {
$scope.showLoader = 0;
isProcessing = false;
//$("body").css('overflow','hidden');
if (ls.length > 0) {
for (var i = 0; i < ls.length; i++) {
$scope.jobslist.push(ls[i]);
}
if (page == 0) {
// $("body").css('overflow','');
// $window.scrollTo(0, 0);
}
if (ls.length < $scope.NEW_SEARCH_PAGE_LIMIT || ls.length==1) {
$scope.nomorejobs = 1;
}
} else {
$scope.nomorejobs = 1;
}
});
};
})
过滤模块:
var filtermodule = angular.module('filtermodule', []);
filtermodule.factory('job_service', ['$http', '$window', function ($http, $window) {
return {
getlastestjobs: function () {
return $http.get('/recruiter/loadlatestjob').then(function (response) {
return response.data;
});
},
getJobList: function (page) {
return $http.get('/recruiter/newsearch', {params: {ajax: '1', page: page}}).then(function (response) {
//console.log(response);
return response.data;
});
},
getRecruiterFunctionalRole: function (page) {
return $http.get('/recruiter/getfunctionalrole', {params: {ajax: '1', page: page}}).then(function (response) {
//console.log(response);
return response.data;
});
},
workList: function () {
return $http.get('/recruiter/worklist', {params: {ajax: '1',page:'1'}}).then(function (response) {
//console.log(response);
return response.data;
});
},
getChartData: function (startdate,enddate) {
return $http.get('/recruiter/getchartdata', {params: {ajax: '1',"startdate": startdate,"enddate": enddate}}).then(function (response) {
//console.log(response);
return response.data;
});
},
reloadGraph: function (startdate,enddate) {
return $http.get('/recruiter/newgetapplicationcounts', {params: {ajax: '1',"from_date":startdate,"to_date":enddate}}).then(function (response) {
return response.data;
});
},
workListCount: function () {
return $http.get('/recruiter/worklistcount', {params: {ajax: '1',page:'1'}}).then(function (response) {
//console.log(response);
return response.data;
});
},
referapplied: function (page) {
return $http.get('/recruiter/referappliedjobs', {params: {ajax: '1',page:page}}).then(function (response) {
//console.log(response);
return response.data;
});
},
referappliedjobcount: function () {
return $http.get('/recruiter/referappliedjobscount', {params: {ajax: '1',page:'0'}}).then(function (response) {
//console.log(response);
return response.data;
});
},
getcompanyjobs: function (companyid,page) {
return $http.get('/recruiter/newcompany', {params: {"ajax": '1',"page":page,"companyid":companyid}}).then(function (response) {
//console.log(response);
return response.data;
});
},
getCompanydetails:function (companyid){
return $http.get('/recruiter/getcompanydetails', {params: {"companyid":companyid}}).then(function (response) {
//console.log(response);
return response.data;
});
},
getMinMaxFixedReferralReward: function () {
return $http.get('/newjob/getminmaxfixedreferalreward').then(function (response) {
return response.data;
});
},
getMinMaxPercentageReferralReward: function () {
return $http.get('/newjob/getminmaxpercentagereferalreward').then(function (response) {
return response.data;
});
},
getMinMaxPerHourReferralReward: function () {
return $http.get('/newjob/getminmaxperhourreferalreward').then(function (response) {
return response.data;
});
}
};
}]);