0

I have this model:

export class TrackingProductoTarjeta {
    id:number,
    color:string
}

And i have this model, which consists of 2 arrays of the TrackingProductoTarjeta model:

import { TrackingProductoTarjeta } from "./trackingProductoTarjeta";

export class TrackingProductoTarjetasData {
   tarjeta1: TrackingProductoTarjeta[] = [];
   tarjeta2: TrackingProductoTarjeta[] = [];
}

Now, lets say i have an instance of the "TrackingProductoTarjetasData" model called "tarjetas", with 2 objects inside each of its arrays.

I want to put it inside a primeNG dataview. The problem is i dont know exactly how to do this, i tried this:

 <p-dataView [value]="tarjetas" [paginator]="true" [rows]="10">

                    <ng-template let-tar pTemplate="gridItem">
                        <div *ngFor="let item of tar.tarjeta1">
                            {{item?.color}}
                        </div>
                    </ng-template>
         
                </p-dataView>

What i want to do is have 1 instance of the TrackingProductoTarjetasData moden and make 1 DataView row for tarjeta1 and another for tarjeta2, displaying the content inside of them. Is that possible?

1 Answer 1

0

How about this?

// This will be the items we display in the view
targetaElements: TrackingProductoTarjeta[] = [];

set tarjetas(data: TrackingProductoTarjetasData) {
    this.targetaElements = [...data.tarjeta1, ...data.tarjeta2];
}

And I guess your view would be something like this:

 <p-dataView [value]="targetaElements" [paginator]="true" [rows]="10">
    
    <ng-template let-item="tar" pTemplate="gridItem">
        <div>
            {{item?.color}}
        </div>
    </ng-template>
    
</p-dataView>
1
  • Thank you! That did the trick :) Sep 29, 2021 at 13:34

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.