I'm getting a bit confused with Angular/Typescripting here. I thought that properties are to be kept hidden to prevent any possible external alteration to a properties value.
For example:
export class Foo{
private _bar: string;
constructor(private bar: string){
this._bar = bar;
}
public get bindBar(): string {
return this._bar;
}
}
And some template
<span>{{ bindBar }}</span>
But in reading there are performance issues with having binding to a method from the html template as methods get called under every change detection that occurs on the page.
Options that I am seeing are to either make it a public property or to use Pipes.
Pipes just seem like overkill to have to implement for every property in a page that you need to bind and public vars have almost always been a no no.
I cannot find any clear direction on the Angular website on how to implement binding and not have a negative impact on performance but also this pipe thing just does not seem the right way of doing it.
Can someone explain?
Thank you for the links to other articles. In them I found an example of the triggering method calls and branched the example to test if it was component based or contained within a component.
As you can see in the example it is not bound to a component as the events triggered affect the other components. My Stackblitz 2 component test