syntaxe diff

10 views
Skip to first unread message

Xavier Artot

unread,
Sep 17, 2014, 10:40:18 AM9/17/14
to ang...@googlegroups.com
I don't undestand the difference between:
My factory name is "myData'.

  angular.module('AngularJS.controllers', ['appMeteoServices'])                                              

    .controller('MainCtrl', ['$scope', function ($scope, myData, $http) {  


  var appMeteo= angular.module('appMeteo', ['ngRoute','appMeteoServices']);                                    

   appMeteo.controller('myCtrl', function($scope, myData, $http) {         


Sander Elias

unread,
Sep 17, 2014, 10:57:41 AM9/17/14
to ang...@googlegroups.com
Hi Xavier,

In the first sample, you are only injecting $scope, the other parameters will be undefined.
The second sample does not explicitly list the injectables, and angular will parse the function.toString() to find what it needs to inject.

The downside of the second notation is that you can't minify your script. At least, not without the help of extra tools.

Regards
Sander

Xavier Artot

unread,
Sep 17, 2014, 1:18:05 PM9/17/14
to ang...@googlegroups.com
I used Grunt and uglify, and is like I can minify, thank for that.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/ED1fmA86akg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--

Xavier ARTOT



Eric Eslinger

unread,
Sep 17, 2014, 1:21:16 PM9/17/14
to ang...@googlegroups.com
If you want to minify safely and not use the array notation, check out ng-annotate. 99% of the time, it works every time. 

Eric

--
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 angular+u...@googlegroups.com.

Xavier Artot

unread,
Sep 17, 2014, 2:26:55 PM9/17/14
to ang...@googlegroups.com

On Wed, Sep 17, 2014 at 12:20 PM, Eric Eslinger <eric.e...@gmail.com> wrote:
g-annotate

ng-annotate, sa c'est cool :)
Thank you


--

Xavier ARTOT



Xavier Artot

unread,
Sep 17, 2014, 2:27:25 PM9/17/14
to ang...@googlegroups.com
Very help full @Eric
--

Xavier ARTOT



Reply all
Reply to author
Forward
0 new messages