How to call the data in page.html


#1

Hi guys can you help me on how to call this type of JSON data in HTML ?

here’s my JSON data in my read.php

[{"id":"17","files":"11.17.17.xls","title":"awdawd","description":"wdwad"},
{"id":"18","files":"OJT-form-BSIT-3-2.doc","title":"wew","description":"awa"},
{"id":"19","files":"11.2.17.xlsx","title":"21515","description":"525465"}]

and this is my main.html ,

    provider.loadData()
    .then(data => {
     console.log(data);
     this.fileData = data;
    })
  }

How can i call it in my main.html ?

i use this code ,

<ion-content padding>
    <ion-list>
     <a *ngFor="let file of fileData">
       <h1>{{files}}</h1>
       <h2>{{title}}</h2>
       <p>{{description}}</p>
     </a>
    </ion-list>
  
  </ion-content>

and im getting error…
please help me


#2

Should be:

     <a *ngFor="let file of fileData">
       <h1>{{file.files}}</h1>
       <h2>{{file.title}}</h2>
       <p>{{file.description}}</p>
     </a>

#3

Hi sigmundFroyd , thanks for quick reply , i use your code but my main.html is blank ,

How can i display the data in my main.html ?


#4

What does your console output?


#5

This my console , Im trying to load the json data from my php .
but I can’t load it… please help me how to fix this.


#6

404 error is server side

So your php script/server is not giving you results


#7

Tommertom , how can i fix this ? can you give me sample tutorial or article that can solve my problem… i tried a lot but nothings work


#8

Its a problem at your server not ionic.

So u need to fix the server

What r u running as server?


#9

And read https://angular.io/guide/template-syntax on templates


#10

Thanks for helping me guys ’ i made it now ! :slight_smile: