html - 继续两个单独数组的索引顺序
问题描述
我有一个具有“X”数组的对象(请注意,这些可以更大或更小):
note: PONotes
allNotes: Array(6)
0: PONote {_text: "Contratación", _date: "", _author: ""}
1: PONote {_text: "Acordamos día de instalación con el técnico de Jazztel", _date: "", _author: ""}
2: PONote {_text: "Instalación y entrega de equipos. Ya puedes Navegar. Iniciamos la portabilidad de tu linea fija", _date: "", _author: ""}
3: PONote {_text: "Linea activada el día de tu portabilidad", _date: "", _author: ""}
4: PONote {_text: "Iniciamos la portabilidad de tu línea móvil", _date: "", _author: ""}
5: PONote {_text: "Introduce Nueva Sim el día de tu portabilidad", _date: "", _author: ""}
length: 6
__proto__: Array(0)
__proto__: Object
我已使用以下函数将此对象分成两个数组:
private getOrderNotes(orderNotes: ProductOrderModel) {
this.activationDeadlinesGraphicViewModel.phoneNumberOrderNotes = orderNotes.note.getAllNotes()
.slice(0, this.activationDeadlinesGraphicViewModel.state);
this.activationDeadlinesGraphicViewModel.cellphoneNumberOrderNotes = orderNotes.note.getAllNotes()
.slice(-this.activationDeadlinesGraphicViewModel.type);
}
切片中的状态和类型为我提供了每个数组所需的项目数。
这是this.activationDeadlinesGraphicViewModel.phoneNumberOrderNotes的数组
(4) [PONote, PONote, PONote, PONote]
0: PONote {_text: "Contratación", _date: "", _author: ""}
1: PONote {_text: "Acordamos día de instalación con el técnico de Jazztel", _date: "", _author: ""}
2: PONote {_text: "Instalación y entrega de equipos. Ya puedes Navegar. Iniciamos la portabilidad de tu linea fija", _date: "", _author: ""}
3: PONote {_text: "Linea activada el día de tu portabilidad", _date: "", _author: ""}
length: 4
__proto__: Array(0)
这是this.activationDeadlinesGraphicViewModel.cellphoneNumberOrderNotes的数组
(2) [PONote, PONote]
0: PONote {_text: "Iniciamos la portabilidad de tu línea móvil", _date: "", _author: ""}
1: PONote {_text: "Introduce Nueva Sim el día de tu portabilidad", _date: "", _author: ""}
length: 2
__proto__: Array(0)
我必须在有序列表中打印它,第一个数组编号从 1 到 4,第二个数组编号从 5 到 6。
因为它们在单独的数组中,所以我打印索引并添加 +1,所以它不会从 0 开始。对于第一个数组,它就像一个魅力,但由于第二个数组再次从 0 开始,我不知道如何将索引更改为下一个我需要基于最后一个数组的数字。
<ng-container *ngFor="let phoneNumberOrderNotes of activationDeadlinesGraphicViewModel.phoneNumberOrderNotes; let i = index;">
<ion-row>
<ion-item>
<ion-col col-1>
<span [class.numberCircleFilled]="activationDeadlinesGraphicViewModel.baseType > i"
[class.numberCircleUnfilled]="activationDeadlinesGraphicViewModel.baseType <= i">
{{ i+1 }}
</span>
</ion-col>
<ion-col col-11>
<span>{{ phoneNumberOrderNotes.text }}</span>
</ion-col>
</ion-item>
</ion-row>
</ng-container>
<ng-container *ngFor="let cellphoneNumberOrderNotes of activationDeadlinesGraphicViewModel.cellphoneNumberOrderNotes; let i = index;">
<ion-row>
<ion-item>
<ion-col col-1>
<span [class.numberCircleFilled]="activationDeadlinesGraphicViewModel.baseType < i"
[class.numberCircleUnfilled]="activationDeadlinesGraphicViewModel.baseType >= i">
{{ i+1 }}
</span>
</ion-col>
<ion-col col-11>
<span>{{ cellphoneNumberOrderNotes.text }}</span>
</ion-col>
</ion-item>
</ion-row>
</ng-container>
最后两个应该是 5 和 6。
解决方案
添加phoneNumberOrderNotes.length
到您的最后一个i
以获得连续编号。
推荐阅读
- rust - 将 tokio::task::JoinHandle 存储在 HashMap 中并从另一个任务中访问它
- android - 我可以在我的应用程序的网络视图中使用其他人的网站吗?
- join - SQL Join queries on related data
- c++ - m_installedLocation = Package::Current().InstalledLocation(); function does not work
- r - Generating faceted pie charts to indicate weightages
- frontend - Why I can't enable frontend editing (TYPO3 Extension frontend_editing) in TYPO3 9.5?
- assembly - 除法的意外结果取决于我使用的是 EAX、AX 还是 AL
- python - Why network with linear layers can't learn anything
- javascript - Error with sending embed link with discord webhook using JS
- sql - 使用postgres进行字符串操作,如何删除第一个位置的字符(如果存在)