【发布时间】:2014-11-06 10:53:54
【问题描述】:
所以我有这样的服务:
.service("checkSystemStatus", ["$http", "statusUrl", function($http, statusUrl){
return $http({method: "GET", url: statusUrl, cache: false});
}])
使用此标记:
<li ng-mouseenter="checkStatus()">
<i class="fa fa-info-circle"></i>
<div class="info-container">
<h4>System Info</h4>
<table class="system-info">
<tr ng-repeat="(key, value) in systemInfo">
<td>{{key}}</td>
<td>{{value}}</td>
</tr>
</table>
</div>
</li>
还有这个功能:
$scope.checkStatus = function(){
$scope.systemInfo = {};
checkSystemStatus.then(function(success){
$scope.systemInfo.running = success.data.jobs_running;
$scope.systemInfo.queued = success.data.jobs_queued;
$scope.systemInfo.cached = success.data.jobs_cached;
$scope.systemInfo.active_threads = success.data.threads_active;
$scope.systemInfo.server_address = success.data.server_address;
$scope.systemInfo.server_port = success.data.server_port;
console.log($scope.systemInfo);
})
}
问题是我总是得到相同的 systemInfo 值,每当我悬停信息图标时,除了第一个之外,我在控制台中看不到任何 XHR 请求,这发生在加载页面时,而不是在我悬停时鼠标在标签上。
到目前为止,解决这个问题的唯一方法是在 url 末尾添加一个参数,例如
?time=unixtime
每次都获取一个新的 url,但是没有尾随参数的更清洁的解决方案呢?可能吗?
【问题讨论】: