1

So I have a dynamic table in angular where im passing data in, then creating the table. I want to add some CSS in order to check the values then add some styling onto it. So if the value is a minus number, then display the data in red

I have used attribute data to check the actual data, which works fine until i call to typescript method to generate the data instead of hardcoding the data in, and this is where is goes wrong. So I want to call this method to get the data instead, and it just displays the method name instead of the method return

1

You can use the attribute binding of data instead of the interpolation if the data returned by the method is not a string - more details here

[attr.data]="getData(header, body)"
  • I removed the interpolation of the method, and it still displays as the method call instead of the data returned. When I added [] around the data I got an error stating Can't bind to 'data' since it isn't a known property of 'td'. – 2345678 Aug 13 at 14:45
  • I edited the answer. But still, can you add the code of getData ? – edkeveked Aug 13 at 14:50
  • Hey man! thank you so much that has worked now! Have you got a link to learn more about data attributes where you found that or is it just your experience and knowledge? – 2345678 Aug 13 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.