After successfully splitting an array into parts, I decided to add some filters to only include the items in the list that have an action status of (4). However, I encountered a problem where the while loop couldn't read the length of the array.
This is the code snippet I'm using:
lf = [];
rows = [];
size = 4;
logframes$: any;
constructor(private logframe: LogicalframeworkService) {
}
ngOnInit() {
this.logframe.getLogicalFrameworks().subscribe(
data => this.setTitle(data)
);
}
setTitle(array) {
array.forEach(item => {
const card = {
'id': item.id,
'title': item.project.description
};
this.logframe.getAuditTrailStatusByLogFrame(item.id).subscribe(
(data: any) => {
if (data.logFrameActionStatusReferenceId === 4) {
this.lf.push(card);
console.dir(this.lf);
}
}
);
});
while (this.lf.length > 0) {
this.rows.push(this.lf.splice(0, this.size));
}
}