I know this is an old post, but could you elaborate further on how you could encapsulate functions to prevent them from being visible on the scope inspite of being in the controller? I am using Typescript and cannot find an answer to hiding helper functions from the scope when using $scope=this.
On Wednesday, May 29, 2013 5:05:07 AM UTC-7, Alan Klement wrote: > > > A few things for everyone to consider. > > > - Everyone has a different interpretation of what good design and > 'best practices' are. This argument shouldn't be used for / against a > feature. > - Your entire controller is not exposed (if I understand correctly). > Don't use the 'this' in syntax 'this.mVariable' to keep methods & data > encapsulated. > - The syntax 'Ctrl as myCtrl' leads to more explicit code (esp. in the > case) as someone else has mentioned here before. Explicit > implicit. > - As Lindquist points out in the video, it is more ECMA 6 - like. As > an experienced OO programmer, exposing data in this fashion feels very at > home. I think other OO programmers moving to Angular / JS will instantly > get it. > - The existing way still works and (correct me if I'm wrong) even with > the new syntax, you can still inject $scope and work that way. > - Promoting an easier what to work with nested controllers > and segregate data will help contribute to more modular designs. > - As Lindquist also points out, you won't run into the issue > of accidentally manipulating primitives. > > Again, the argument of it's not 'good design' isn't enough for me > - simply because everyone has a different idea of was 'good design' is. > > On Thursday, May 23, 2013 9:20:08 PM UTC-4, Ben Clinkinbeard wrote: >> >> Exposing your entire controller to your views is bad practice IMO. $scope >> is a great way to mimic a presentation model/view > > -- 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.
