0

I have comp-chil

`@Input() ObjectChild:any;`

comp-parent

<comp-child [ObjectChild]=checkValue(0,1)></comp-child>
checkValue(p1, p2){ return {p1:p1*(dosomething), p2:p2*dosomething};

It still work, but when I click anywhere fuction checkValue always call.

1 Answers1

0

That's how Angular change detection works.

It's a bad idea to call the function in the template.

You might want to rewrite your code to either use:

  1. a getter to serve your purpose
  2. let the child decide what to do with the value.
  3. Use pipe to do the logic in the template if you really have to do it. Pipes result are memoized, so they are not going to redo the function logic if the input value has not changed.