Hi Sander,

Yes that would work. Yet somehow it doesn't feel right ;-)
You'll have to admit this looks better:

angular.module('app')

    .provider('Logger', function() {
        var module = ''

        this.setModule = function(module_) { module = module_ }

        this.$get = function() {
            return {
                info: function(message) {
                    console.info(module + '::' + message)
                }
            }
        }
    })

    ._clone('Logger2', 'Logger')    // <------ here's the magic

    .config(function(LoggerProvider) {
        LoggerProvider.setModule('root')
    })
    .config(function(Logger2Provider) {
        Logger2Provider.setModule('root 2')
    })


That's actually working locally, I hacked around a bit. Too big of a hack
to show that code. :-)






On Thu, Mar 6, 2014 at 3:14 PM, Sander Elias <[email protected]> wrote:

> Hi Antoine,
>
> Sure there is. I use a trick to put in small util functions inside
> angular. You know the special small things you never know where to put..
> In most of my applications I have a module utils, that looks something
> like:
>
> ```
>     var util = {};
>     angular.module('util', []).
>         value('util', util);
>
>
>     util.sometool = function (string) {
>         //do something
>         return string;
>     };
> ```
>
> Of course this is inside a IFFE.
> There are a number of variant possible to this, but it should get you
> going!
>
> 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