Reputation: 4289
Is it possible to bind a property to a service function?
I am trying something like this:
View:
<app-grid [header]=namingConventionService.getResourceText("something")></app-grid>
In the Service:
getResourceText(key: string) {
if (this.namingConvention) {
return this.namingConvention[key];
}
}
I get a console error: Template parse errors: Unexpected closing tag...
Upvotes: 0
Views: 129
Reputation: 31115
Yes, try enclosing the function in quotes.
<app-grid [header]="namingConventionService.getResourceText('something')"></app-grid>
Notice the single quotes surrounding something
. That is how constant literals are used in templates.
Upvotes: 2
Reputation: 73731
Enclose the binding in double quotes, and the inner string in single quotes:
[header]="namingConventionService.getResourceText('something')"
Upvotes: 0