Currently, I am using SockJS to listen to websocket events and receive objects that I want to insert into my $scope.mails.items
array. The issue I am facing involves the code snippet below. For some reason, I am unable to pass the message
parameter into my delayed function. Despite trying to find explanations for this problem, I have not been able to understand why it is not working in this specific scenario. I need to delay the execution of this function to ensure it applies correctly to my view.
MyService.receive().then(null, null, function(message) {
$timeout(function(m) {
if($scope.mails.items.indexOf(m) == -1) {
$scope.mails.items.push(m);
}
}, 0, true, message);
});
While debugging, I can confirm that the message
variable contains the correct value. However, when the delayed function pauses, the variable m
does not contain the data even though I expect $timeout
to pass it through.
I would appreciate any assistance you can provide with this issue.