1

I have a data-table with some data, on a click at any row we get some detail information, the details come from JSON File and i want to rename the value with key value. Because the data looks like "some_information" and i wanna show somenthing like "Some information"

I was thinking i could do it with map in child Component, or with ngSwitch Loop in child html file. But it's not working.

Working Stuff here

1 Answer 1

1

Before assigning the dataSource, you can do the following to modify the name value:

ELEMENT_DATA.forEach(el => {
  // first we replace any '_' with an empty space
  // then we capitalize each first letter of `name` words.
  let modifiedName = el.name.replace(/\_/g, ' ');
  modifiedName = modifiedName.charAt(0).toUpperCase() + modifiedName.slice(1);
  el.name = modifiedName;
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.