I'm currently using getUserMedia to capture an audio stream. The audio stream is only accessible within the getUserMedia callback function. However, I have encountered an issue where Angular fails to detect changes and update the bindings when I attempt to modify them from within the callback. Despite following advice from various sources to use $scope.$apply, it doesn't seem to have any effect.
You can view my attempted solutions in this fiddle: http://jsfiddle.net/poptart911/a00koc8r/1/
angular.module('test', [])
.controller('mainController', function ($scope) {
this.deviceStatus = "Angular is functioning.";
this.deviceStatus = "Updating a binding works fine.";
navigator.mediaDevices.getUserMedia({
audio: true,
video: false
}).then(function (stream) {
this.deviceStatus = "Angular fails to recognize this change.";
$scope.$apply(function (stream) {
this.deviceStatus = "I even tried $scope.apply!";
alert("However, I am aware that this code is executing");
});
});
});