RC0: TypeScript 'private' vs. 'public' keyword


#21

Didn’t know that compiler will complain. I was just blindly converting everything to public. Now I’ll keep everything private and convert to public whatever complier says.


#22

That makes a whole lot of sense, and makes the entire thing a lot more intuitive; thanks for clearing it up, once and for all.


#23

This is related.


#24

I don’t think _http needs to be public. I declared it as private in my app and works fine with RC1. The code compiled and working fine.
Or may be I missing something in my own code :slight_smile: and here as well.


#25

Hi all sorry to bring this old topic up again. Just to be clear in all my constructors the variables are set as private. Currently I do not have any errors as I am not accessing any of them through the template. What is the best practice for Ionic? That is convert them all to public or only to public where it is needed?

Also if I changed them to public will it have any effect on performance etc? Thanks just looking for the clarification on best practice here.


#26

The only ones that need to be public are those accessed in templates. There is zero effect on performance: access control is purely a build-time concept. At runtime it doesn’t exist at all.


#27

Are these templates as in ionic start blah [template-name]?


#28

Template as in the .html file for a given page/view.