JacobTristan
JacobTristan

Reputation: 45

Getting property from observable in a component

I am trying to return a property with an observable within the component. I can successfully retrieve the property in the template but I do not need it there:

{{(selectedOrder$ | async).orderNumber}}

It correctly shows the order number in the template.

I have tried to do something like this:

this.selectedOrder$.pipe(select(order=> {
    this.selectedOrderNumber$ = order.orderNumber;
}));

For some reason, that returns a 404 error when I launch my application.

Upvotes: 0

Views: 23

Answers (1)

veben
veben

Reputation: 22262

If selectedOrder$ is the Observable, you have to subscribe to it in order to recover the value within the component:

this.selectedOrder$.subscribe(order => {
  this.selectedOrderNumber$ = order.orderNumber;
}));

Upvotes: 1

Related Questions