I just begin working with angular 2. so I try to display categories from data base using web service.
this is my forum.service.ts file
public getCategories(){
return this.http.get('http://localhost/ForumLaraAngular/public/api/forum').map((res: Response) => res.json());
}
forum.component.ts:
categories:any;
constructor(private forumService:ForumService) { }
ngOnInit(): void {
this.forumService.getCategories().subscribe((data)=>{this.categories=data;})
}
forum.component.html:
<categories>
<ul>
<li *ngFor="let categ of categories"> {{categ.titre}}</li>
</ul>
</categories>
Any help please,thanks in advance
Write following lines of code out of selector
<ul>
<li *ngFor="let categ of categories"> {{categ.titre}}</li>
</ul>