I'm struggling to pass data between a service and a controller in my AngularJS project.
Even though I've followed the recommended steps, the code is not functioning as expected.
Below is the controller snippet:
function udpController($scope,$interval,udpService) {
$scope.status = udpService.status;
$interval(function(){udpService.changeStatus();},2500);
}
And here is the corresponding service section:
angular.module('udpTest').service('udpService' ,function() {
var self = this;
this.status;
this.changeStatus = function() {
self.status = Math.random();
}
}
The $scope.status
remains unchanged despite the implemented logic.
Appreciate any guidance on resolving this issue.