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

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.

3 Likes

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.

This is related.

1 Like

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.

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.

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.

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

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