Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 将数据从json自动刷新到angular_Angularjs_Json - Fatal编程技术网

Angularjs 将数据从json自动刷新到angular

Angularjs 将数据从json自动刷新到angular,angularjs,json,Angularjs,Json,你好,我想创建自动刷新,因此当数据更新时,字段也会更改。因此,我尝试使用$interval。请检查我的脚本 <script> var app = angular.module('myApp', []); app.controller('listsupport', function($scope,$http,$interval) { var count = 0; $http.get("<?=base_url();?>newch

你好,我想创建
自动刷新
,因此当数据更新时,字段也会更改。因此,我尝试使用
$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>

var-app=angular.module('myApp',[]);
app.controller('listsupport',函数($scope,$http,$interval){
var计数=0;
$http.get(“newchat/listsupport”)。然后(函数(响应){
$scope.names=response.data;
$interval(函数(){listsupport();},10000);
}); 
});
使用上面的脚本,我得到一个错误
listsupport未定义
。我怎样才能修好它?提前感谢。

试试这个

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);
});
var-app=angular.module('myApp',[]);
app.controller('listsupport',函数($scope,$http,$interval){
this.interval=$interval(函数(){
$http.get(“newchat/listsupport”)。然后(函数(响应){
$scope.names=response.data;
});
}, 10000);
});

您在哪里定义函数
列表支持