Angular 2的新手也许有点基础。显示Observable <any[ ]> HTML内的返回类型
我有一个服务功能getMedia其是可观察到的类型的任何[]返回在订阅该信息到组件:
本质上,这是对象数组所以在我的分量I写这个:
export class RecommendationFeedComponent implements OnInit {
result:Array<Object>=[];
constructor(private feedService: FeedService, private authService: AuthService,
private auth: FirebaseAuth, public af: AngularFire) { }
ngOnInit() {
this.af.auth.subscribe(
(user) => {
if (user) {
this.feedService.getMedia(user.auth.email)
.subscribe(result => this.result = result);
console.log(this.result);
}
})
}
控制台返回空,所以我不知道如何使用它来显示HTML上的数据。
更改的组件和模板:低于这个
<tr class *ngFor="let media of (result)">
<td>
<img src={{media.data.images.standard_resolution.url}} height="100" width="100">
</td>
</tr>
有什么errorr:
然后你的模板里面? – Milad
我的不好,就像你提到的那样。我有另一个错误。感谢帮助! Upvoted。 –
那好吧,接受吗? – Milad