외부 변수와 통신하기 위해 전역 변수를 사용하고 있습니다. 그래서 내가 사용한다AngularJs 전역 변수 지우기
window.report = $scope.myData // my scope with all data
문제는 내가 보고서를 실행하려고 할 때 나는 먼저이 전역 변수를 재설정하고 다시 채워야한다.
이 문제를 일으키는 부분 템플릿 캐시 될 수 있을까요 ....window.report = null;
window.report = {};
그러나 이전 데이터가 아직 거기에 새로운 데이터를 덮어 쓰기 없습니다 경우입니다 :
나는 함께 시도?
콘솔에 로그온하려고했으나 window.report 변수가 정의되지 않았습니다. 그래서 문제는
는[업데이트]를
여기서 문제 아마 서비스입니다 ... 다른 곳에서해야한다.
app.factory('Report', ['$http', function($http,$q){
var Reports = {
reports : {},
requests :[{'url':'getReport','response':'Analizing page','count':1},
{'url':'getPagerank','response':'Getting 1','count':2},
{'url':'getRobots','response':'Getting 2','count':3},
{'url':'getIpCanonicalization','response':'Gwetting 3','count':4}]
]
};
Reports.getReport = function(target, source, response, callback) {
return $http({ url:"/seo/getter/",
method:"POST",
//cache: true,
params:{"url" : target, "action": source}
}).success(function(result) {
callback(result);
console.log(Reports.reports)
jQuery.extend(true,Reports.reports, result.data)
//console.log($scope.user)
}).error(function(error){
callback(result);
jQuery.extend(true,Reports.reports, result.data)
})
}
Reports.startQueue = function (target, callback) {
var promises = [];
this.requests.forEach(function (obj, i) {
promises.push(Reports.getReport(target, obj.url, obj.response, function(response,reports){
callback(obj.response,Reports.reports,obj.count)
}));
});
}
return Reports;
}])
나는 내보기를 업데이트 할 때 Reports.reports VAR 여전히 오래된 데이터가 포함되어 있다고 생각합니다. 따라서 문제는 글로벌 변수가 아니어야하며 이전 데이터를 계속 가져 오는 서비스 여야합니다. 업데이트 할 때 Report.reports가 비어 있음을 어떻게 확인할 수 있습니까?
시도 . 당신도 일정한 시도를 할 수있다. – Whisher
항상 시험해 보았다! 캐시 문제 일 수 있습니까? – Tropicalista
더 많은 코드를 게시하려고합니다 – Whisher