*vm* ≈ *$ctrl* : True that *$* is generally a *loaded* prefix. I want to 
respect that, but I also want to be consistent for the mental context 
switching reason you hit on. Either by replacing my usage of *vm* as a 
namespace in templates or to continue using the controllerAs: 'vm' 
convention in components. What's your strategy?

*$onInit* ≈ constructor : Different events in the ctrl lifecycle for sure. 
In truth, snuck it in b/c it was a shiny new thing i wanted to play with in 
a plunk. Haven't done much to grok it yet. But I can't figure a legit use 
case for it outside context of a component or directive controller. 

*angular.extend()* : mos def only in constructor and always immediately. I 
personally just find defining my instance props in a block to be good 
ergonomics. Maybe an artifact from my PHP days... but it is nice to have a 
regular place to eye-scan for that stuff. RE: runtime overrides... isn't 
that just javascript tho? Other than by using something like 
*Object.freeze()*, I think that risk is always there. 

On Friday, March 4, 2016 at 11:02:39 PM UTC-6, Sander Elias wrote:
>
> Oh, this just hit me, so here is a small addendum to my previous post!
>
>>
>>>    - constructor => #$onInit() ✔
>>>
>>> No, in ng1, the controller itself is 'constructed' way before the 
>> $onInit, $onInit will get called, once all required controllers are 'newed' 
>> up. It is a replacement for the post/pre-link concepts.  
>>
>
> If you start doing this in all your controllers, you will create new 
> problem. You don't know in what order the controller's get their call to 
> $onInit. This means that if you need something from another required 
> controller, you can't be sure it is already 'done'. Seems to me that 
> defeats the whole purpose on $onInit (which is to act on something after 
> all relevant controllers are created!). 
>
> 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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to