Quantcast
Viewing all articles
Browse latest Browse all 9

Answer by Franklin Pious for Angular2 - should private variables be accessible in the template?

A workaround could be using private variables in ts file and using getters.

private _userName = "Test Name";get userName() {  return this._userName;}

This is a good approach because the ts file and the html remains independent. Even if you change the _userName variable name in ts file, you dont have to make any change in the template file.


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>