NjMinko NjMinko - 4 months ago 13
JSON Question

How to use ngfor to print property of object?

<div *ngFor="let article of articleList;let i = index">
<div class="item">
<div class="image-holder"
style="background-image: url(https://c9.io/blog/content/images/2015/07/ninja-1.jpg)">
<a href="https://c9.io/blog/title-wip-cloud9-shortcutfoo/"></a>
<div class="title">
<a class="title-ref" href="#">{{article.title}}</a>
<div class="text">
{{article.description}} <a class="text-ref" href="#">>></a>
<div class="item-header">
<div class="author">
<img class="img-circle"
src="https://c9.io/blog/content/images/2015/05/brady.jpg" />
<span class="author-name"><a class="user-ref" href="#">{{article.user.name}}</a></span>
<div class="time">2015-07-31</div>

I can see the
, desprition etc. but the article.user.name is undefined. if
, it will show object.

How to get print


I think that you should use the safe navigation operator like this-


This link could give you more details: https://angular.io/docs/ts/latest/guide/template-syntax.html. See the section "safe navigation operator ( ?. ) and null property paths"

See if this helps.