0
votes

i'm using angular 7 with @ngrx.
I've reproduced the issue i'm having on stackblitz, here is the link

If you check the console, after clicking on the active/Unactive checkbox, you'll see that in the child component (supplier-card-item.component) the model is being updated correctly but when being emitted to the parent component (supplier-card-list.component), the object is restored to its original value which is the one stored in the state container.

Store's actions, effects, reducers, etc... are in the root-store folder.

Thank you for your help

1
updateSupplier(obj){ return 200; } code is not completed?rijin
the object received in the function UpdateSupplier() is the original one, so this part doesn't really matters or am i wrong?Arnaud Delubac

1 Answers

0
votes

Problem is with what you are emitting back((child_hasChange)="onSupplierUpdate($event)")

        <app-supplier-card-item *ngFor="let supplier of suppliersActive" 
        [supplier]="supplier"
        (child_hasChange)="onSupplierUpdate($event)" <<- here
        ></app-supplier-card-item>
    </mat-tab>

    <mat-tab label="Inactive">
        <app-supplier-card-item *ngFor="let supplier of suppliersUnactive" 
        [supplier]="supplier"
        (child_hasChange)="onSupplierUpdate($event)" <<- here
        ></app-supplier-card-item>
    </mat-tab>
</mat-tab-group>