mercredi 1 janvier 2020

Golang unable to display slice of structs in html

I am working on a project which requires me to retrieve data and display it on a html.

The data is stored and pass to the html as slice of structs.

The data consists of different fields (eg. name, temperature, humidity ...) The data retrieval part is working (I have confirm by printing it out and displaying the Golang slice on my html). However, what I want to achieve is displaying the data properly in a table according to their fields. I have attached my code and there isn't any output. I couldn't find the errors.

Please help me with this. Thank you

*P.S All the names/labels are spelled correctly.

This is the screenshot of the output

This is the code:

<div style="overflow:auto;">
        

        <table class="table table-striped">
                <thead>
                  <tr style="text-align: center;">
                    <th scope="col">Time</th>
                    <th scope="col">Name</th>
                    <th scope="col">Temperature</th>
                    <th scope="col">Humidity</th>
                    <th scope="col">Ambient</th>
                    <th scope="col">Red</th>
                    <th scope="col">Green</th>
                    <th scope="col">Blue</th>
                  </tr>
                </thead>
                <tbody>



        

        <tr style="text-align: center;">

          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        
    </tbody>

  </table>
    
        <h1 style="font-size: 3vh;margin-top:10vh;">No data available</h1>
    



  </div>



Aucun commentaire:

Enregistrer un commentaire