Perhaps I’m trying to use too-complex signals, let me know if what I am trying to achieve is just not a good use-case for Angular’s Signals and I guess I’ll try a different approach, but I feel like this should be do-able!
I have a service which is managing the state of an order – the order class contains some properties, one of those properties is an array of OrderItems.
I have created a signal for the Order PackingOrder = signal<order>(orderFromDB);
Which I can access just fine, but I am unable to figure out how to update an OrderItem within the order.
Given a Signal containing an Order object built using classes as below, how would one update, say, a specific OrderItem’s ‘packed’ property (given the OrderItem’s id)?
export class Order {
id: number; //USING THIS TO IDENTIFY THE ITEM...
customer: string;
orderItems: OrderItem[];
}
export class OrderItem {
id: number;
produceName: string;
unitQty: number;
container: string;
yield: number;
packed: number; //<--HOW TO UPDATE THIS?
complete: boolean;
}
I have searched for a solution but everything I have found has been targeting an array itself as the signal, or a simpler object, I’ve been unable to extend those answers into a working solution for this case, so here I am!