Skip to content
Advertisement

Angular 11, how to data-bind a value from a function

I got a list of values that has to be shown, i’m using two elements for databing, here’s my component:

JavaScript

and here’s my html document

JavaScript

Everything works fine but one of the values I have to show is the sum of {{element.announces}} and {{element.withdraws}}, I have tried adding a ‘sum’ function in my component and then calling it in my html document like this:

JavaScript

The output is exactly the string written there, not the value returned from the function. What is the correct syntax for what I’m trying to do, is a function even necessary?

Advertisement

Answer

You need to put your method call inside the {{ }}.

E.g.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement