Use custom service in config()

Showing 1-5 of 5 messages
Use custom service in config() wingy 8/14/12 11:18 PM
In this demo I am trying to get a service I declared in the config() method.


It says it cannot be found.

Is there a way to make this work?

Wingy
Re: Use custom service in config() Marco Alves 8/15/12 3:05 AM
Just out of curiosity, why are you doing that?
Re: [AngularJS] Use custom service in config() Pawel Kozlowski 8/15/12 3:23 AM
hi!

On Wed, Aug 15, 2012 at 8:18 AM, wingy <johnn...@yobistore.com> wrote:
> In this demo I am trying to get a service I declared in the config() method.

It won't work since during the config phase service instances are not
created yet. You've got access to providers only (which are kind of
blueprints for creating instances). What you could do is to use the
'run' phase to do something with your service instances:
http://plunker.no.de/edit/9nF9H6?live=preview

In short:
1) In the config phase you've got only access to constants and
providers. Instances are not yet created at this point.
2) In the run phase instances are already created, you can't play with
providers anymore here.

Check the "Module Loading & Dependencies" section in
http://docs.angularjs.org/guide/module

Cheers,
Pawel

> http://plunker.no.de/edit/zEVozN?live=preview
>
> It says it cannot be found.
>
> Is there a way to make this work?
>
> Wingy
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to
> angular+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en.
>
>
Re: [AngularJS] Use custom service in config() Johnny Luu 8/15/12 4:37 AM
The thing I want to do is to log each HTTP response and request.

And for that to happen I need to use MyLogger inside config() since there is where you configure the $http request and response formatters.

It seems that there is no way to do this in the config() handler.

Wingy
Re: [AngularJS] Re: Use custom service in config() Johnny Luu 8/15/12 4:38 AM
Read my other response.

Wingy

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.