angular: Component methods must be public for AOT to work when accessed from the template...
Component methods must be public for AOT to work when accessed from the template…
IMO its wrong.
A component should be able to mark its properties and methods as private and still allow its template full access (AOT or not).
Remember this is not just a pure class, its a component and the view is part of it.
And just to prove my point, if you can refer to this
in a template, and this
== the Component / Class, why would you have to mark the methods of the controller / component as public?
Now to make things worse, WebStorm is following this pattern and so it will not allow for refactorting and other helper intelisence as per this PR: https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FWEB-24234#comment=27-1730331
I beg to re-evaluate this as forcing public on all members of a component just to expose it to the view / template will add uncertainty on OOP and the core concept of encapsulation will be forgone 😦
regards
Sean
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 16 (7 by maintainers)
By definition, they must be public. This isn’t Angular’s opinion or anything.
The psuedo-code version of what’s happening looks like this
The generated HostComponent, again, “hosts” the component instance, and accesses its properties from the outside - so its just regular Typescript semantics.
Couldn’t the GeneratedHostComponent just extend the component?