javascript - Referring to external function parameter within $timeout -
i listening websocket events sockjs , want insert received objects $scope.mails.items array. have below code snippet , problem reason not able pass message delayed function. know... tried read explanations issue asked repeatedly, still not able figure out why not working in particular case. reason need delay i'd make sure gets applied view, not otherwise.
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); }); when debugging it, can see message variable has proper value when comes stopping in middle of delayed function, m not getting data, expect $timeout pass down.
can please help?
not sure why m not getting value (explanation welcome), works:
myservice.receive().then(null, null, function(message) { $timeout(function() { if($scope.mails.items.indexof(message) == -1) { $scope.mails.items.push(message); } }, 0, true, message); });
Comments
Post a Comment