Monitor global variable from AngularJS -


i want monitor value of global variable angular. have flash movie records microphone data , pushes out global variable. reference variable angular this:

$scope.audiodata = $window.audiodata; $scope.$watch('audiodata', function() {     console.log("audio in angular!:", $scope.audiodata.length); }); 

and in html i've put:

<h1>{{audiodata.length}}</h1> 

in html can see audio data changed after recorded, watch function not being called while it's recording, need stream audio server.

there 2 things keep in mind here.

the first $watch default watches identity of objects , array, doesn't notice if there changes inside value. can solved watching length or using third argument yoshi has mentioned.

the second thing remember angular check watches when triggers it. if nothing happening in angular-world, no watches or callbacks executed. since recorder lives outside of angular-world, needs notify angular has been changed. can done calling $apply after updating recording. alternate way consider have angular update @ regular intervals using $timeout.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -