Hi Sander, thank you for the reply. I'm aware of the functionalities available in $scope which are tricky when using Controller/as. I'm also aware that using Controller/as is problematic when it comes to callbacks - I'm talking about context changing /*this* not pointing controller anymore/. I know there are workarounds for those (angular.bind, assing var t = this; etc) but still, they're workarounds.
I'm wondering if there is anything that justifies usage of Controller/as and overcoming mentioned problems. The only thing that crossed my mind is inheritance, it'd be obvious to inherit the controller itself, not the scope. >From my understanding the Controller/as makes Angular MVC-like (View has direct access to Controller), while the $scope is kind of ViewModel. This makes me wonder again, which one is the recommended way as of Angular 1.3? Could you please elaborate more on the lifetime of $scope vs Controller? Is that about instatiating $scope when injecting dependency? On Tuesday, June 3, 2014 4:22:37 PM UTC+2, Sander Elias wrote: > > Hi Migajek, > > The advantage is that it is easier to comprehend. Also, in the view/html > its more clear where your data is coming from. > There is also a difference in life-time between a controller and a scope. > Also a scope comes with build-in goodies like $scope.$watch/$emit/$on/... > Those are not directly available to a controller. > > Is that enough to answer your question? > > 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.
