请帮助:((下注)
我的mysql数据库中有一个存储雪崩图书时间的表;
在我的网站,有按钮,用户可以点击,并得到相关的雪崩图书时间,你可以看到图片所附。
每次用户点击左右箭头时,我都会触发一个工厂函数,然后我会得到一个包含与那天相关的雪崩书籍的数据,到目前为止,一切都很好。
Problem:当用户第一次进入我的站点时,我将得到当前的一天,我将显示与这一天(今天)相关的雪崩图书时间,当用户点击左右箭头时,我将在三天后得到与之相关的雪崩书籍。效果也很好。
但这是Slow。
我希望当用户进入我的网站时,我会得到与今天相关的数据,直到两个月后。
但我只想展示今天(第二天和第二天)的雪崩书籍。因此,当用户单击左/右箭头时,我将不必调用另一个http请求,并强迫用户等待数据雪崩才能看到。
是否有一种方法可以定义一些异步http请求并存储回调成功数据,但是在用户点击一个特殊的键(在我的例子中是左/右箭头)之前,不要使用它?
下面是我在工厂中的http请求函数:
app.factory('ShowBookingFacDrProfile',function($http){
return{
showbooking:function(scope){
$http.post("partials/search-drprofile/show_available_books.php",{today,nextday,next2day})// I just simplicized the object that I send here
.success(function(msg){
scope.booking=msg;;
//here I want to do something like this :
then.post('sameURL',{next3day,next4day,next5day})
// I want to repeat this until 2 month later from today
then.post('sameURL',{next6day,next7day,next8day})
}
}
});
相关主计长:
$scope.hitArrow = function(current) {
$scope.pager = current;
SearchFac.search($scope);
};
在我的控制器里注意到特殊
我知道我可以用承诺!,但如何存储它们?在哪?以后怎么用?
我不能将它们存储在一个新的scope.booking中,例如: scope.booking2,因为这样我就不能正确地使用它们:
我不能使用缓存,因为也许每时每刻雪崩书都变了:
这是我的看法:
<div class='col-xs-4'>
<table class='table table-responsive' >
<tr data-ng-repeat='v in booking |filter:{month:date.next2month} |filter:{day:date.next2day}'>
<td><a>{{v.hour}}</a></td>
</tr>
</table>
</div>
<div class='col-xs-4'>
<table class='table table-responsive' >
<tr data-ng-repeat='v in booking |filter:{month:date.nextmonth} |filter:{day:date.nextday}'>
<td><a>{{v.hour}}</a></td>
</tr>
</table>
</div>
<div class='col-xs-4'>
<table class='table table-responsive' >
<tr data-ng-repeat='v in booking |filter:{month:date.today} |filter:{day:date.today}'>
<td><a>{{v.hour}}</a></td>
</tr>
</table>
</div>
注意到实际上我在这个站点点击中看到了这种方法
请看,点击箭头,你将看到新的雪崩图书时间有多快进入视图
发布于 2014-06-19 22:08:43
如果$scope.预订是一个数组,您只需附加http响应(array.push(对象))的内容即可。
https://stackoverflow.com/questions/24316956
复制相似问题