Hi, im trying to find the way to fetch an array from collection and displaying it on the template without iterating. This is what i have
@Component({
selector: 'blog',
template,
styles: [ style ]
})
export class BlogComponent {
articleSub: Subscription;
articles: any;
error: string;
public quotesArray;
constructor() {
this.articleSub = MeteorObservable.subscribe('articles').subscribe(()=>{
this.articles = Articles.find({}, {sort:{date: -1}}).fetch();
console.log(this.articles[0].autor);
});
}
}
this correctly displays the author in my console, but when i try to bind it to the template as
<h2 class="title"> {{articles[0].title}}</h2>
I get
EXCEPTION: Cannot read property ‘0’ of undefined
What is the correct way to do this?
Im using angular 2 and can’t work around a *NgFor
Thank you very much