Comment on actual development - Angular UI's ngGrid uses string reference
to data variable. They allow the use of both object reference and string
name, but string name is the only one that supports data updates.
The reason is that they use $watch to watch the data.
I just found that I can't cleanly use "controller as" together with ngGrid
for that reason - my controller doesn't know what name to pass to ngGrid,
as it doesn't know it's own name. There are several workarounds that I am
considering, but in general this will be an issue as you can't cleanly
watch the content of the controller. I really need to know the string name
of the controller at the time of construction for a simple solution.
On Thursday, February 20, 2014 5:02:00 PM UTC-5, Кошелев Иван wrote:
>
> >>$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 <javascript:>
> *Sent:* Thursday, February 20, 2014 23:16
> *To:* [email protected] <javascript:>
>
> 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] <javascript:>.
> To post to this group, send email to [email protected] <javascript:>
> .
> 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/d/optout.