因此,我正在研究RESTAPI,它正在angular中使用,并以以下格式获得响应
我得到了简短的描述,但当我试图用*NGO来展示它时,因为它不起作用,我在angular方面是一个绝对的初学者,所以任何指导都会很有帮助的,谢谢
{
"data": {
"Query": "sample query",
"numbers": [
"0013290",
"160011736",
"130004057",
"2075333",
"0015416"
],
"Scores": [
94.66,
94.48,
78.12,
0.17,
0.15
],
"Short_descriptions": [
"sample 1",
"sample 1",
"sample 1",
"sample 1",
"sample 1"
],
}
}
this.query='{ "query": "sample query" }';
this.homeService.getTop5KbArticles(this.query).subscribe(data => {
this.KBdata =data["data"];
this.shortDesc =this.KBdata["Short_descriptions"]
<div class="col-md-5" *ngFor="let x of shortDesc">
<p>{{x.Short_descriptions}}</p>
</div>
1条答案
按热度按时间a6b3iqyw1#
代替
{{x.Short_descriptions}}
具有{{x}}
.当你写作的时候
*ngFor="let x of shortDesc"
,意思是x
将是一项shortDesc
它是一个简单字符串数组。