Private methods called from html compile without errors


#1

I remember, somewhere, that private methods, for design best practice reason I guess, weren’t allowed to be called from the html pages. Therefore, if a private method would have been used in an html pages, the build compilation used to throw an error … well if that’s correct, seems it is not the case anymore.

Could someone could tell me, first, if I’m totally wrong? and if not, if you notice the same unexpected behavior?

P.S.: I noticed that error because I just wrote a private method I only call from the html page

'navigateToDetail' is declared but never used.

P.P.S.: Same behavior noticed with ionic server or ionic cordova build android --prod


#2

It’s not for design practice reasons. ngc generates separate TS classes for templates, and they are unable to access private properties from the controller. I believe what is going on is that ionic-app-scripts (perhaps only sometimes) does an end-run around this with the way that it invokes ngc. It’s still a dangerous thing to rely on. Anything accessed from templates should be public.


#3

good to know.

so we just assume that app-scrip do this check sometimes and “no worries” about it?

I was really thinking that app-scripts use to not compile when such private methods where use from the html pages, since it’s dangerous, and seems know that this check isn’t performed anymore.