Thanks Tony.
I have implemented the $rootScope.$apply inside the service.
Then, I have figured out that my CPU consumption was due to the fact that
$interval calls $root.$digest. So I have modified my code so that it calls
$scope.$digest which is much less CPU expensive.


On Sun, Apr 6, 2014 at 11:18 AM, Tony pee <[email protected]> wrote:

> oh, but if you want to call code in the controller, not just reference the
> value in the template (partial). then you will want to use a $watch in the
> controller code
>
>
> On 6 April 2014 01:16, Tony pee <[email protected]> wrote:
>
>> as long as the interval which accesses *webkitGetUserMedia calls
>> $rootScope.$apply() angular refresh watches when the service calculates the
>> volume. You can then just reference the calculated value directly from the
>> controllers, and when it changes, they will be updated, due to angulars
>> databinding. *
>>
>> *no?*
>>
>>
>> On 6 April 2014 00:34, Yehonathan Sharvit <[email protected]> wrote:
>>
>>> I have a service that is connected to the microphone (
>>> *navigator.webkitGetUserMedia*) and calculates the microphone volume ~
>>> every 20 msec.
>>> I would like to access the calculated volume from two controllers.
>>>
>>> The only solutions I found are:
>>> 1. to use $interval from inside the controller. But it takes a lot of
>>> CPU resources.
>>> 2. to fire an event from the service and listen to the event from the
>>> two controllers.
>>>
>>>
>>> Any other suggestions?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "AngularJS" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/angular.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Tony Polinelli
>>
>>
>
>
> --
> Tony Polinelli
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/2YTE29npJHI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"Are we what we become or do we become what we are?" - Prof. Beno Gross

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to