On Mon, Sep 22, 2014 at 7:22 AM, Jens Melgaard <[email protected]> wrote:
> Thats not really true...
>
> .controller('TakeGPSData', ['$scope', '$http', function(s, h)
>
> Will work just as well, so will
>
> .controller('TakeGPSData', ['$scope', '$http', function() {
> var scope = arguments[0];
> var httpService = arguments[1];
> }]);
>
>
Those work - we don't recommend either style here, but I agree it at least
the first one is totally valid.
>From my experience with teams adopting angular, I would not recommend the
> use of ng-annotate for new angular developers, they need to learn how and
> why it works this way.
> Remove the magic from the equation, so to speak...
> Alternatively always use the explicit way in ng-annotate, you will have to
> use it eventually as ng-annotate won't cover all cases out of the box where
> frameworks may provide inject-able functions.
> That will also give you a "demystification" of why it works which helps
> new people to understand...
>
>
I agree with this too! We teach an AngularJS class, so I've worked with
lots and lots of people first using AngularJS. The DI mechanism is a
mystery to most new AngularJS developers, which makes me wonder if the
AngularJS docs/web/etc could do a better job featuring it. In class we go
through how the mechanism works in detail. (But for production code, we do
what I wrote before.)
I think this name-based DI mechanism is on it way out anyway. AngularDart
does DI based on types already, I believe.
--
Kyle Cordes
http://kylecordes.com
--
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.