I've implemented $timeout
in my controller but it doesn't seem to be functioning correctly.
app.controller("Friendsrequests",['$http','$log','$location','$timeout','$scope', function($http,$log,$location,$timeout,$scope){
// Accessing the base URL of the application
this.baseUrl = function() {
var base_url = window.location.origin;
var pathArray = window.location.pathname;
return base_url;
// return base_url+pathArray;
};
// Assigning the base URL to a variable ('login/f_request')
var ThroughUrl = this.baseUrl()+'/keon/login/f_request';
// Declare a variable
var ata = this;
ata.notifications = [ ] ;
ata.counts=' ';
// Sending an AJAX request
function getNotifications()
{
$http({method: 'POST', url: ThroughUrl,})
.success(function(data) {
// Callback when the response is available
// Assign data to the notifications variable
ata.notifications=data;
ata.counts =data.length;
}).
error(function(data, status, headers, config) {
// Handle errors
});
}
$timeout(function() {
getNotifications();
}, 1000);
}]);
- What could potentially be causing the issue?