Dlaczego data w widoku nie reaguje na zmiany w modelu?

0

Hejka, mam następujący kod:

<div ng-controller="APP.Timer">{{czas}}</div>
APP.Timer = function ($scope){
function getTime() 
{
    var data = new Date();
    var h = data.getHours();
    var m = data.getMinutes();
    var s = data.getSeconds();
    return ""+h+
             ((m<10)?":0":":")+m+
             ((s<10)?":0":":")+s;
}
$scope.czas = getTime();
setInterval(function(){
    $scope.czas = getTime();
    }, 1000);
}

Niestety data nie odświeża się co sekundę; wciąż wyświetla godzinę ostatniego odświeżenia strony. O czym zapomniałam? Co zrobiłam nie tak?

1

https://docs.angularjs.org/api/ng/service/$interval

<div ng-app="firstModule" ng-controller='firstController'>
{{czas}}
</div>
var module = angular.module('firstModule',[]);
module.controller('firstController',function($scope,$interval){
	$scope.czas = getTime();
	$interval(function(){
		$scope.czas = getTime();
		}, 1000);
});
function getTime() 
{
    var data = new Date();
    var h = data.getHours();
    var m = data.getMinutes();
    var s = data.getSeconds();
    return ""+h+
             ((m<10)?":0":":")+m+
             ((s<10)?":0":":")+s;
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1