0

I'm displaying a nested JSON object in a table which has array of strings like obj.someKey = ['a','b','c']. In the td tag of the table I'm directly displaying the array content.

<td> {{obj.someKey}}</td>

What I'm trying is I want to have a space after each element in the UI. I cannot use *ngFor since loop will display the elements in multiple td tags. Is there a way to have a space after comma each elements of the array?

1
  • How about *ngFor with spans? Commented May 29, 2018 at 14:56

2 Answers 2

2

You can use like follow, If that meet your requirements

<td> {{ obj.someKey.join(" ") }} </td>
Sign up to request clarification or add additional context in comments.

1 Comment

I believe better approach is to calculate obj.someKey.join(" ") in .ts file and store in variable; just print that variable in front-end!
0
<td> {{ obj.someKey.join(", ") }} </td>

Output

Accessories, Clothing, Footwear, Textiles, Uniform and Workwear

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.