>>$scope.$watch('controller.varname', ...)

Valid point. But in development I'm yet to encounter a situation where this 
would pose a problem. A lot more often I’m found in a situation where 
controller A uses a variable on the scope that it did not define and I am 
forced to go look for its defining controller by simple text  search for its 
name.


Plus, if you have a variable that will be used somewhere down the scope 
inheritance chain, it is already a good practice to declare it on an object 
attached to a scope as opposed to the scope itself, to avoid accidental 
overshadowing if you write into it. 











From: Guillaume Lecomte
Sent: ‎Thursday‎, ‎February‎ ‎20‎, ‎2014 ‎23‎:‎16
To: [email protected]






Sorry to bring that back but am I the only one who see a design problem here? 

We define an alias in the view/template ( MyCtrl as controller ), if we want to 
watch a variable in the (controller) scope from the controller, we need to know 
the alias we defined in the template ($scope.$watch('controller.varname', ...), 

it's not DRY, it generates coupling and prevent reusing several times the same 
controller (nested).




I'm suggesting a $controllerScope injectable (a $scope 'scoped' on the 
controller) to solve that, does anyone else want something like that?

Le vendredi 14 juin 2013 21:19:12 UTC+2, Guillaume Lecomte a écrit :
Doesn't that feature need a way to inject a controllerScope in the controller 
(a scope where this is the controller) to be able to watch members agnosticly 
of the alias defined in the view to be complete? Or provdide a way to mixin 
that scope in the controller?

-- 
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/84selECbp1I/unsubscribe.
To unsubscribe from this group and all its topics, 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