1

I have worked upon almost all the Angular2+ versions using typescript. I am bit new for VueJs2.

Since in Angular we keep public variables which can be used inside HTML template and private variables are mainly used for processing the information in .ts file.

Since VueJs is also quite similar and follow Angular syntax, however, I am unable to get this below behaviour of variable

In my VueJS with typescript and I am using class based approach, even when I marking a variable as private then also I am able to access it values directly in Vue Tempalte ? CodeLink

How should I differentiate between public & private variables such that, I can keep my private variables for process/manipulate the data.

Whereas when we define private variable in Angular and try to access in HTML it gives us the error CodeLink

Any feedback would be greatly appreciated Thanks.

Himanshu Saxena
  • 340
  • 3
  • 13
  • That's because `#private` is still a [stage 3 proposal](https://github.com/tc39/proposal-private-methods) (without much support). In Angular, it's Angular that's stopping you from using it. If you choose to turn that flag off, you'll see that accessing a private property outside the class actually works (and the template is outside the class). See current support [here](https://caniuse.com/mdn-javascript_classes_private_class_fields). – tao Mar 08 '21 at 22:05

0 Answers0