I'm pretty new to Angular and I'm trying to create a table to better display my data. I'm getting the data from a JSON provided by my server.
Content of data.component.html:
<div class="container">
<h1>Search history</h1>
<table *ngIf="searches">
<li *ngFor="let search of searches">
<p class="searchParams">{{search.searchParams}}</p>
<p class="searchDate">{{search.searchDate | date: "yyyy-MM-dd hh:mm"}}</p>
</li>
</table>
</div>
Content of data.component.ts:
@Component({
selector: 'app-data',
templateUrl: './data.component.html',
styleUrls: ['./data.component.scss']
})
export class DataComponent implements OnInit {
searches: Object;
constructor(private _http: HttpService) {
}
ngOnInit() {
this._http.getSearches().subscribe(data => {
this.searches = data;
console.log(this.searches);
});
}
}
What I get is something that looks like a bullet list:
I'm trying to take this as example but I don't understand how to implement it. What is my datasource here? What HTML should I write to get such a nice looking table?
