저는 AngularJS와 Angular Routing을 사용하고 있습니다. 템플릿 'homeController'에 대한 템플릿 'home.html'및 컨트롤러가 있습니다. 또한,이 공장이있다 : 그 페이지를 클릭 할 때마다템플릿을로드 할 때마다 각도 공장 호출 방지.
app.factory('therapyService', function ($http) {
return {
getTherapies: function() {
//return the promise directly.
return $http.get('http://localhost:8080/application/api/rest/therapy').then(function (result) {
//resolve the promise as the data
return result.data;
});
}
}
});
In controller:
therapyService.getTherapies().then(function (results) {
$scope.therapies = results;
...
}
문제는, 그 HTTP 호출을 다시 한번 호출된다. 페이지가 처음로드 될 때만 처음 호출되기를 원합니다. 그것을하는 방법?
캐싱은 얼마나 오래 지속됩니까? 그리고 고마워, 좋은 작품. – firstChild
@firstChild 캐싱은 응용 프로그램 수명 동안 지속됩니다. –