美好的一天,我想创建auto refresh
,所以当数据更新时,字段也会改变。所以,我正在尝试使用$interval
。请检查我的脚本
<script>
var app = angular.module('myApp', []);
app.controller('listsupport', function($scope,$http,$interval) {
var count = 0;
$http.get("<?=base_url();?>newchat/listsupport").then(function (response) {
$scope.names = response.data;
$interval( function(){listsupport();}, 10000);
});
});
</script>
使用上面的脚本,我收到错误listsupport is not defined
。我该如何解决?谢谢你提前。
答案 0 :(得分:0)
试试这个
var app = angular.module('myApp', []);
app.controller('listsupport', function($scope, $http, $interval) {
this.interval = $interval(function() {
$http.get("<?=base_url();?>newchat/listsupport").then(function(response) {
$scope.names = response.data;
});
}, 10000);
});