getter method VS get syntax in Angular template

Viewed 208

Say in my view I want to get some private properties foo and bar from a class inside my template. I could use a get method or the get syntax.

class Example {

  private $foo = 'foo';
  private $bar = 'bar';

  public getFoo() {
    return this.$foo;
  }

  public get bar() {
    return this.$bar;
  }

}

Assuming example is an instance of the class above, I can now do inside my template:

<span>{{example.getFoo()}} {{example.bar}}</span>

How do these two solutions differ in performance and change detection? Or is there no difference?

0 Answers
Related