Reputation: 63
I am developing my first Angular app and having trouble with string interpolation.
I have a component which contains the following element:
`<span>{{action.getText()}}</span>`
action is of Type Action which has the following method:
getText(): String { return "Test"; }
The variable action is defined correctly since I can access properties via {{}} without a problem. e.g. {{action.title}}
So my question is, is this even possible to access this function and if yes, what am I doing wrong?
Upvotes: 3
Views: 11626
Reputation: 8605
You refer to action.title
, but ation.getText()
. Certainly a typo?
<span>{{action.getText()}}</span>
Upvotes: 0
Reputation: 8605
You could convert it to a property:
get text(): string { return "Test"; }
Your template becomes:
<span>{{ation.text}}</span>
Upvotes: 4