I try to display an array which I fetch from mongodb (Chrome networktool shows that I get it (response with articles)). I dont get any error but the articles arent shown in the template.
Here is the template:
<div class="container-fluid">
<div class="row">
<div *ngIf="articles">
<div class="col-lg-5 sm-12 m-6" *ngFor="let arts of articles">
<div class="list-group ">
<!--TODO: Link to ViewArticle-->
<a href="#" class="list-group-item list-group-item-action felx-column
align-items-start active">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{arts.headline}}</h5>
<small>{{arts.updated_at}}</small>
</div>
<p class="mb-1">{{arts.textarea}}</p>
<small class="text-muted mutedText">
MutedText.MutedText.MutedText.</small>
</a>
</div>
</div>
</div>
</div>
</div>
The getArticles() method in the Component: the articles array is declared!
getArticles():Promise<Article[]>{
return this.articleService.getArticles()
.then(articles => this.articles = articles);
}
And the service's getArticles() method:
getArticles(): Promise<Article[]>{
return this.http.get(`${BASE_URI}${PATH_ARTICLES}`)
.toPromise()
.then((r: Response) => r.json().data as Article[])
.catch(this.handleError);
}
Thanks in advance, I cant find anything on the net..
{{articles}}
somewhere (not inside of the *ngIf, of course) – dquijada Feb 15 '17 at 13:03