我有一个 angularJS 应用程序的工作实现,它从 URL 获取一些链接并绘制它们。但是 URL 上的链接会不断更新,我想定期更新这个 $scope.listlinks,假设每 10 秒更新一次。
我尝试玩 setInterval 没有运气。
Javascript
var App = angular.module('App', []);
App.controller('ListLinksCtrl',
function get($scope, $http ) {
$http.get('http://example_url.com/my_changing_links_json').then(
function(res){$scope.listlinks = res.data;});
}
);
HTML
<div id="cnt1" ng-controller="ListLinksCtrl">
<div ng-repeat="singlelink in listlinks">
<a href="{{ singlelink.url }}">
{{ singlelink.destination }}
</a>
</div>
</div>