Can someone help me with this issue?
When I try to access addons, I only see [] but the web console indicates that addons are present.
This is my JSON structure:
I attempted to use this code:
console.log(vehicle.montage_card.addons);
but it returns an empty array: [].
What am I missing or doing wrong?
UPDATE
In my PrimeNg table, one section looks like this:
<ng-template let-col let-vehicle="rowData" let-index="rowIndex" pTemplate="editor"> <p-multiSelect *ngIf="!viewMode && (continuationContract == 0)" name="client_vehicles{{index}}" [showToggleAll]="false" [style]="{'width':'100%'}" [options]="clientVehiclesOptions" defaultLabel="Open list" [ngModel]="vehicle.assignedContractsID" (ngModelChange)="onSelectedClientVehiclesChange($event, vehicle)" maxSelectedLabels=0 selectedItemsLabel="Selected: {0}." (onChange)="checkSelectedClientVehiclesQuantity(vehicle)" [disabled]="viewMode"> </p-multiSelect> </ng-template>
Here is part of my function where I log the vehicle object:
onSelectedClientVehiclesChange(event: any, vehicle: Vehicle) {
let temp: any[] = [];
let numberExists: boolean = false;
console.log("vehicle");
console.log(vehicle);
console.log(vehicle.montage_card.addons);
event.forEach(element => {
temp.push(this.clientVehicles.client_vehicles.find(clientVehicle => clientVehicle.id == element));
});
}