嗨,我想显示来自响应http的值,但我不知道出了什么问题。
http:
getAllApiContext(){
const options = this.getOptions("...");
return this.http
.get("jenkins/job/api_initialization/api/json", options)
.map((data: any) => {
return data.json().property[0].parameterDefinitions[1].choices;
})
}
她返回数组。
我的component.ts
context: Observable<Array<any>>;
ngOnInit() {
this.jenkinsJob.getAllApiContext().subscribe(data => {
this.context = data;
});
};
我的component.html
<span *ngFor="let item of context | async">
<p>{{item}}</p>
</span>
答案 0 :(得分:4)
在<div class="row" data-equalizer>
<div class="large-5 small-12 columns" data-equalizer-watch>
<img class="show-for-medium-up" src="~/Content/Images/BallCropped-800.jpg" />
</div>
<div class="large-4 small-12 columns" data-equalizer-watch>
<p class="subhead">Middle Text</p>
<ul>
<li>
One
</li>
<li>Two</li>
<li>Three</li>
</ul>
</div>
<div class="large-3 small-12 columns " data-equalizer-watch>
<img src="~/Content/Images/Bottomlogo-400.gif" />
</div>
中删除异步。由于您已经订阅了Observable,因此无需使用异步管道
ngFor
答案 1 :(得分:3)