I'm trying to make my Angular application to be as straight forward readable to other programmers, and I came to this dilemma, I have an method within my component:
onAddPost(): void {
console.log('adding a post!');
}
I want to invoke it on click from a button from my template(of the same component):
<button (click)="onAddPost()">Save Post</button>
so far so good, but then I want to give Access Modifier for running the "onAddPost" only within the given component, and nothing seems to work.
private onAddPost(): void {
console.log('adding a post!');
}
gives me the error of:
"Property 'onAddPost' is private and only accessible within class 'PostCreateComponent'"
I get something similar for 'protected', can someone help me understand what am I missing about Angular? why the template is not part of the component class? and can I limit the access for the methods used in my component?