I am not able to update the values within the view of the page using angularJS. These values are supposed to change after having a call to the method done from the website.
The html element holding the value is
<p>Current song playing: {{currentSong.SongName}}</p>
Here is my angular code, with just the parts relevant to my issue
var myApp = angular.module('myApp', ['ngMaterial', 'ngMessages']);
myApp.controller('myCtrl', function ($scope, $http, $timeout, $q) {
$scope.currentSong = {
SongName: ''
}
loadCurrent().then(function (data) {
$scope.currentSong = { SongName: data };
});
$scope.updateSong = function () {
loadCurrent().then(function (data) {
$timeout(function () {
$scope.currentSong = { SongName: data };
},200);
});
}
function loadCurrent() {
var deffered = $q.defer();
$timeout(function () {
$http({
method: 'GET',
port: '8080',
headers: {
'Content-Type': 'application/json'
}
}).then(function successCallback(response) {
deffered.resolve(response.data.SongName);
}, function errorCallback(response) {
console.log(response)
});
}, 500);
return deffered.promise;
};
});
The initial load current sets the value on the page, however if I call updateSong the value does not change on the page. However, I do see the value change within the $scope during debugging.