Liam,
I am not sure that you need to toString() your functions. If you want to
prevent duplication in your arrays, can you not just use
thingInMyArray.indexOf(newFunction) == -1?
But then, your head-scratcher sounds like it might be encouraging its own
itch. Can you say a little more about what you are trying to accomplish?
Best,
SS
On Friday, May 16, 2014 11:47:17 AM UTC-4, Liam Ryan wrote:
>
> I have a bit of a head-scratcher.
>
> I'm trying to implement an observer service to provide $scope.$watch
> functionality to services.
>
> I add a callback function to an object : function[] map based on the
> following logic, assuming newCallbackFunction is the callback I'm trying
> to add
>
>
> angular.forEach( thingInMyArray, function( existingFunction ) {
> if newCallBackFunction.toString() === existingFunction.toString() {
> //don't add
> }
> })
>
> I want to ensure that if I have two controllers with the same update
> method that they will both be notified, not just the function that was in
> the array first. Any 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.