在自动刷新时将 AngularJS 数据加载到 table
Load AngularJS Data to table on automatic refresh
我有一个 table 显示从数据库到 AngularJS 的值:
<div class="container wrapper" ng-controller="DbController">
<table class="table table-hover">
<tr>
<th>NUMĂR ORDINE</th>
<th>NUME CLIENT</th>
<th>ACȚIUNE</th>
</tr>
<tr ng-repeat="detail in details| filter:search_query">
<td>{{detail.id}}</td>
<td>{{detail.nume_client}}</td>
<td>
<button class="btn btn-warning" ng-click="editInfo(detail)" title="Preiau client"><span class="glyphicon glyphicon-edit"></span></button>
</td>
</tr>
</table>
我找不到可以在几秒后自动刷新 table 以重新加载新数据的函数。有没有一种方法可以在不手动刷新页面或单击按钮的情况下执行此操作?
我有一个刷新跨度的函数,但我不知道如何使它适应 Angular:
<script type="text/javascript">
function refreshDiv()
{
$("#refresh").load("includes/assets/receptie_clienti/databaseFiles/get_client_count.php");
}
window.setInterval(refreshDiv, 1000);
</script>
和HTML:
<span id="refresh">0</span>
//初始值为0,当新值加入数据库时会发生变化
LE: 固定喜欢选择的答案:
修改后的AngularJS控制器:
var ClientsApp = angular.module('ClientsApp',[]);
ClientsApp.controller("DbController",['$scope','$http','$interval', function($scope,$http,$interval){
// Refresh the data automatically to get clients details from the database
$interval(callAtInterval, 1000);
function callAtInterval() {
$http.post('includes/assets/receptie_clienti/databaseFiles/get_clients.php').success(function(data){
// Stored the returned data into scope
$scope.details = data;
});
}
尝试在您的控制器中使用 $interval 刷新详细信息。
$interval(function() {
$scope.detail = 'call your getData service here';
}, 1000);
ClientsApp.controller("DbController",['$scope','$http', $interval, function($scope,$http,$interval){
...
}
我有一个 table 显示从数据库到 AngularJS 的值:
<div class="container wrapper" ng-controller="DbController">
<table class="table table-hover">
<tr>
<th>NUMĂR ORDINE</th>
<th>NUME CLIENT</th>
<th>ACȚIUNE</th>
</tr>
<tr ng-repeat="detail in details| filter:search_query">
<td>{{detail.id}}</td>
<td>{{detail.nume_client}}</td>
<td>
<button class="btn btn-warning" ng-click="editInfo(detail)" title="Preiau client"><span class="glyphicon glyphicon-edit"></span></button>
</td>
</tr>
</table>
我找不到可以在几秒后自动刷新 table 以重新加载新数据的函数。有没有一种方法可以在不手动刷新页面或单击按钮的情况下执行此操作?
我有一个刷新跨度的函数,但我不知道如何使它适应 Angular:
<script type="text/javascript">
function refreshDiv()
{
$("#refresh").load("includes/assets/receptie_clienti/databaseFiles/get_client_count.php");
}
window.setInterval(refreshDiv, 1000);
</script>
和HTML:
<span id="refresh">0</span>
//初始值为0,当新值加入数据库时会发生变化
LE: 固定喜欢选择的答案:
修改后的AngularJS控制器:
var ClientsApp = angular.module('ClientsApp',[]);
ClientsApp.controller("DbController",['$scope','$http','$interval', function($scope,$http,$interval){
// Refresh the data automatically to get clients details from the database
$interval(callAtInterval, 1000);
function callAtInterval() {
$http.post('includes/assets/receptie_clienti/databaseFiles/get_clients.php').success(function(data){
// Stored the returned data into scope
$scope.details = data;
});
}
尝试在您的控制器中使用 $interval 刷新详细信息。
$interval(function() {
$scope.detail = 'call your getData service here';
}, 1000);
ClientsApp.controller("DbController",['$scope','$http', $interval, function($scope,$http,$interval){
...
}