Log*_*gik 2 html javascript typescript angular-directive angular
我想知道如何在数组元素之间放置逗号,而行尾没有逗号。有类似的问题,但我的有点不同,因为我使用 *ngFor 指令来显示文本:
<span *ngFor="let style of styles">
{{style}} //If I put a comma after the text, there would be a comma at the end of the line after the
//last element was displayed
<span>
Run Code Online (Sandbox Code Playgroud)
解决我的问题的方法是什么?
Pie*_*Duc 10
您可以使用以下last值*ngFor:
<span *ngFor="let style of styles; let last = last">
{{style}}<ng-container *ngIf="!last">,</ng-container>
<span>
Run Code Online (Sandbox Code Playgroud)
或者您可以使用以下first值*ngFor:
<span *ngFor="let style of styles; let first = first">
<ng-container *ngIf="!first">,</ng-container> {{style}}
<span>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
469 次 |
| 最近记录: |