I'm evaluating JS frameworks to use for a project and I'm stuck between Angular and Ember. Before I finish my evaluation of Angular, I need to know if there is an easy way to bind data to an external json file stored on S3.
My use case is to create a scoreboard using data that will be published live to S3 periodically... usually ever 15 seconds or so.
Right now, I'm just creating a basic scoreboard page with data from a local json file, but is there a way to make the data in index.html update when the json file changes or am I stuck with having to make some sort of callback?
Any help is appreciated. Thanks!
// app.js
var App = angular.module('App', []);
App.controller('ScoreboardCtrl', function($scope, $http) {
$http.get('scoreboard.json')
.then(function(res){
// Storing the json data object as 'scores'
$scope.scores = res.data;
});
});
The idea is to create a scoreboard by cycling through scores:
<!doctype html>
<html ng-app="App" >
<head>
<meta charset="utf-8">
<title>LIVE</title>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="ScoreboardCtrl">
<ul>
<li ng-repeat="score in scores">
{{score.home_team_score}} - {{score.away_team_score}}
</li>
</ul>
</body>
</html>