Skip to main content
added 1192 characters in body
Source Link
Iggsy
  • 113
  • 1
  • 2
  • 13

I have followin problem:

enter image description here

When I tied to get addons I just get [] but web console show me that I have addons.

My json structure:

enter image description here

I just tried to do this:

console.log(vehicle.montage_card.addons); but I have this result: []

What am I doing wrong?

EDIT

I have PrimeNg table, this is little part of this table:

      <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="Wybrano: {0}." (onChange)="checkSelectedClientVehiclesQuantity(vehicle)"
          [disabled]="viewMode">
        </p-multiSelect>
      </ng-template>

And this is my function when I console.log the vehicle:

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));
});
}

I have followin problem:

enter image description here

When I tied to get addons I just get [] but web console show me that I have addons.

My json structure:

enter image description here

I just tried to do this:

console.log(vehicle.montage_card.addons); but I have this result: []

What am I doing wrong?

I have followin problem:

enter image description here

When I tied to get addons I just get [] but web console show me that I have addons.

My json structure:

enter image description here

I just tried to do this:

console.log(vehicle.montage_card.addons); but I have this result: []

What am I doing wrong?

EDIT

I have PrimeNg table, this is little part of this table:

      <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="Wybrano: {0}." (onChange)="checkSelectedClientVehiclesQuantity(vehicle)"
          [disabled]="viewMode">
        </p-multiSelect>
      </ng-template>

And this is my function when I console.log the vehicle:

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));
});
}

How to get data from nested jsonJSON in typescriptTypeScript?

Source Link
Iggsy
  • 113
  • 1
  • 2
  • 13

How to get data from nested json in typescript?

I have followin problem:

enter image description here

When I tied to get addons I just get [] but web console show me that I have addons.

My json structure:

enter image description here

I just tried to do this:

console.log(vehicle.montage_card.addons); but I have this result: []

What am I doing wrong?