0

I have data returned from api with this format :

[
  {
    "game": "Among Us",
    "playTime": 5000,
    "genre": "Multiplayer",
    "platforms": [
      "PC",
      "Android"
    ]
  }
]

I'm showing it into bootstrap table, but the platforms content won't be displaying ! how to loop for it ?

<table class="table table-striped">
        <thead>
            <tr>
                <th scope="col">Game</th>
                <th scope="col" sortable="name">Genre</th>
                <th scope="col" sortable="area">Plateforms</th>
                <th scope="col" sortable="population">Total play time</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let game of topGamesUsers">
                <td>

                    {{ game.game }}
                </td>
                <td>{{ game.genre }}</td>
                <td>{{ game.plateforms }}</td>
                <td>{{ game.users }}</td>

            </tr>
        </tbody>
    </table>

should I store them into another variable or I can do this in html file ?

2
  • And if you want to actually loop it - just do ngFor="let platform of game.platforms" Commented Jun 3, 2021 at 12:27
  • @tymeJV inside tr or td ? Commented Jun 3, 2021 at 12:30

2 Answers 2

1

You can show it as a comma separated string in the row by using =>

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

Comments

0

You can try like this.

<td>
    <div *ngFor="let platform of game.platforms"></div>
</td>

4 Comments

I've edited your answer to use block formatting, which is more readable for multi-line code samples. Please review to ensure that the formatting is correct. Notably, I removed the backticks around the asterisk, as I don't believe they're needed here, and were part of your effort to maintain correct formatting.
Thank you. I will follow your feedback.
No problem. As you'll have noticed, I've edited a handful of your posts to improve clarity and formatting, which will hopefully improve their reception. I appreciate your contributions and eagerness to participate in the community; welcome.
cool. I gonna to be eagerness member of stackoverflow. :)

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.