Hi Yarslav,

In typescript a private is intended to be used within the class itself, and 
any access from the outside should be prohibited. Technically, privates 
should be inaccessible from the template. Due to the fact that it compiles 
down to JS, and TS only does type-checking during dev and compile time, it 
is possible to access privates from the template. However, with ES6 it is 
possible to create true private instance variables. A future version of TS 
might utilize this. When/If it does this, this option will render templates 
that relay on private instance vars useless.

While I like the sentiment that DrewMoore is expressing, strictly speaking, 
using privates inside templates is not ok. They work because there is a 
void between TS and the level of protection ES5 can deliver. 

That's a TS issue more as it has anything to do with NG. 

advice, don't use TS privates at all, as this is a confusing issue. If you 
insist on privates, don't use them in the templates, but be aware that they 
are in fact available (no so private at all!)
if you really wan't privates, use some symbols, there are a couple of good 
blogs around how to create real privates in ES6, and even in ES5 (although 
that's much harder to do, and not 100%)

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