как правильно написать данный код и как обновляют данные в angular?
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>Расписание</title>
<script>
var c = {
formatTime: function(b) {
b = Math.floor(b / 1E3);
var a = Math.floor(b / 60),
d = Math.floor(a / 60);
b %= 60;
a %= 60;
return c.two(d % 24) + " час. " + c.two(a) + " мин. " + c.two(b) + " сек. "
},
two: function(b) {
return (9 < b ? "" : "0") + b
}
};
angular.module("app", []).controller("TabsDemoCtrl", function($scope, $http) {
$scope.json = '["12:00", "12:10", "12:35", "23:37"]';
$scope.arrString = JSON.parse($scope.json);
$scope.myArray = [];
$scope.fn = function ()
{
$scope.myArray = [];
angular.forEach($scope.arrString,
function(el) {
el = el.match(/\d+/g);
var date = new Date;
date.setHours(+el[0], +el[1],0,0);
date = date.getTime() - (new Date).getTime();
$scope.myArray.push(date < 0 ? "Автобус ушел" : "Осталось : " + c.formatTime(date));
})
console.log($scope.myArray)
window.setTimeout($scope.fn,1000)//не смог сделать вывод новых данных
}
$scope.fn()
});
</script>
</head>
<body>
<ul ng-controller="TabsDemoCtrl">
<li ng-repeat="bustime in arrString track by $index">
{{bustime + ' ' +myArray[$index]}}
</li>
</ul>
</body>
</html>