Internally Angular is instantiating the Provider immediately, getting rid
of the original provider function, which is making a second instance
impossible.

BTW this cloneProvider should be a more generic solution such that
factories and services can also be cloned.




On Thu, Mar 6, 2014 at 3:03 PM, Antoine van Wel
<[email protected]>wrote:

> Hi Sander,
>
> Well I see your point but there's no escape to defining global functions
> if you want your service definitions spread across multiple files.
>
> The fifth and last method I've described (which could be described as a
> meta-provider) is actually not satisfactory as it requires to rewrite your
> factories the moment you want to instantiate them more often. Actually I'm
> surprised it even works.
>
> I'm getting the impression what I want cannot be done without making
> changes in Angular's core DI; i.e. multiple instances of Providers, such as
> (thinking out loud here..)
>
> angular.module('app')
>     .cloneProvider('RootLoggerProvider', 'LoggerFactoryProvider')
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Thu, Mar 6, 2014 at 2:22 PM, Sander Elias <[email protected]>wrote:
>
>> Hi Antoine,
>>
>> Your first try was actually quite close! You don't need an global
>> function, but you can use a function.
>> have a look at this plunk <http://goo.gl/JOk7CK>. In your case, have a
>> close look at services.js.
>>
>> Does this help enough? If you want/need I can dig in deeper.
>>
>> Regards
>> Sander
>>
>> --
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.

Reply via email to