我们的代码是home.html
<div *ngFor="let Server of Servers; let i = index; let f=first; let l=last;" >
<p> {{Servers}}</p>
</div>
在home.ts
中创建的数组,如下所示
Servers=['1','2','3'];
我希望home.html
页面上的结果应该像:
1
2
3
请告知。
答案 0 :(得分:1)
应该是,
<div *ngFor="let Server of Servers; let i = index; let f=first; let l=last;" >
<p> {{Server}}</p>
</div>
答案 1 :(得分:0)
您已在{{Servers}}
代码中添加{{Server}}
而非<p>
。
<div *ngFor="let Server of Servers; let i = index; let f=first; let l=last;" >
<!-- Change to this -->
<p>{{Server}}</p>
<!-- Change to this -->
</div>
简单的例子是:
<div *ngFor="let item of Servers;" >
<p>{{item}}</p>
</div>
答案 2 :(得分:0)
最合乎逻辑的解决方案:
<ion-list>
<ion-item ion-item *ngFor="let Server of Servers; let i = index; let f=first; let l=last;"">
<p> {{Server}}</p>
</ion-item>
</ion-list>
棘手的(不推荐):
<div *ngFor="let Server of Servers; let i = index; let f=first; let l=last;" >
<p> {{Server}}</p>
<br/>
</div>