Imad Imad - 1 year ago 144
TypeScript Question

Calling component function from template

In template

<tr *ngFor='let activity of pagedWorkflowActivities' [style.background-color]="setBackgroundColor(activity)">

In component

setBackgroundColor(activity: WorkflowActivity) {
return 'red';

I wrote this code in the component in which all other events that are related to same template is written. So I think it is the right place. I just can't get it worked as I am getting this error in developer tool.

self.parent.context.setBackgroundColor is not a function

Answer Source

This is ridiculous, I was trying too many things to make it work but you know what solved it? I just reset IIS (as I am using Asp.Net) and rebuild the solution and it worked. I was getting same problem few days ago and I gave it up but the next day this issue was gone automatically. Might be caching issue but frustrating one.

Edit You can also try ipconfig /flushdns command that prevents rebuilding solution unnecessarily.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download