javascript - Watch not being called on array push -
i have service peerjs contains array of active streams. when setting webrtc stream there callback called when stream becomes available
call.on('stream', function(stream){ activestreams.push(url.createobjecturl(stream)); }); when stream available push onto activestreams array. watch array value in controller this:
//peerrtc service , .getactivestreams returns activestreams array $scope.$watch(peerrtc.getactivestreams, function(activestreams) { $scope.activestreams = activestreams; }, true); but reason watch callback doesn't execute when push url(string) value array.
am overlooking something? because activestreams value changing in callback function?
some condition, async call, need call $scope.apply() make work. try call right after push new data array.
Comments
Post a Comment