last day (15 days later) » 

9:30 PM
hi
Can i ask for clarification about the comment you wrote ?
 
Ian
yeah of course
 
you said : as for a real-life scenario, I like to put each controller's code into separate files (and bundle/minify them later). I don't want a global variable (or variables) floating around just to declare components. So I declare component groups - angular.module("testApp.controllers", []);, declare the main module - angular.module("testApp", ["testApp.controllers"]);,
 
Ian
yep
 
But I could also do in my first code :
angular.module('phonecatApp', []).controller('PhoneListCtrl', ['$scope', '$http',
       function ($scope, $http) {
       ...
       }]);
 
Ian
yep of course
 
9:34 PM
and then in another file :
angular.module('phonecatApp', []).controller('PhoneListCtrl2222222222222', ['$scope', '$http',
       function ($scope, $http) {
       ...
       }]);
So - i dont understand your claim : " to put it in seperte files"
I couldl do it
but i still dont see how second is better
(second approach)
 
Ian
you wouldn't. technically, you'd need to do angular.module('phonecatApp').controller(... - note the lack of [] in the .module() call.
but let me try to explain more
you're right though
i've gone through many iterations of how i declare modules and components in my angular apps
the first one was var app = angular.module("app", []); and I referenced app throughout my other files... app.controller("Ctrl", ...)
then i realized i didn't need the global variable
so i still did angular.module("app", []); in one file. then in another file angular.module("app").controller("Ctrl", ...)
 
which is my first approach
I think the global variable confuses people
(destract them from the question)
Im talking about :
ngular.module('phonecatApp', [
  'ngRoute',
  'phonecatControllers'
])
andd then later :
angular.module('phonecatControllers', []).controller('PhoneListCtrl', ['$scope', '$http',
  function($scope, $http) {
   ...
  }]);
I dont see the difference
 
Ian
but for some reason i found/realized you can group components into their own modules and inject them in your main module. so i started doing it that way. hopefully my comments didn't come across as one approach being better than another.
but at the same time, like i said, it CAN help you organize things in a way that you can easily take them out and put somewhere else (but if you never plan on doing that, why bother?). i never plan on doing it, but i have an organization OCD problem where i feel better about it when they're organized differently.
 
Ok thanks for your help
 
Ian
if you make a "phonecatControllers" module, you have a descriptive way of knowing exactly what's in that module, and you can move it around (if need be)
sorry if i'm not doing a good job explaining it all though
 
9:42 PM
:-) thanks
bye :-)
 
Ian
no problem! bye!
 

last day (15 days later) »