Sander, I had read this long back - put "Define 1 component per file." But my project has atleast 30 controllers and 30 factory methods. The no of files might grow even further very soon.
I'll have to link them all to the index.html page! Doesn't it look awkward? And is that the actual way to do stuffs? Ya, functions are permitted in angular and I've plenty of them. But I want to have a single function which is accessible from all controllers! I can't(probably) write a factory method and inject it into each controller. Because these repeat codes are factory methods and some functions which get values from view. I want to take out all those repeat code and put it in one place and include in inside each controller - just link a method call. ..feeling confused! On Thursday, January 29, 2015 at 12:20:07 PM UTC+5:30, Sander Elias wrote: > > Hi Satish > > You should really read through a style guide, > <https://github.com/johnpapa/angularjs-styleguide> a lot will fall into > place for you. > First of all, all JS files should just hold a single entity. an entity > being a controller, a directive or a service. > > You should not be writing repeated code, there is no need for that. There > are quite a number of ways to take care of that, and keep > your code neat and DRY. > > You can put the repeated code into a service, of a utility function. (yes > you can have functions inside angular!) > > More questions? just ask them! > 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/d/optout.
