I have an object that I get via an observable called compModel
. It gives me a large configuration object that I need to use to adjust pieces of dom. One of the things I want to do is make some checkboxes be checked/unchecked according to this model, but I can't access their respective properties.
<input type="checkbox" checked="{{compModel | async}}">
null
and the box is not checked at any point. I think this is interpreted as passing the obj
property of an observable to the async pipe, which returns null because the observable itself doesn't have obj
, the future data does.<input type="checkbox" checked="{{compModel.obj | async}}">
Cannot read property boolean of undefined
. The boolean value here is what I'm after. How do I get it?<input type="checkbox" checked="{{compModel.obj.boolean | async}}">
<input type="checkbox" checked="{{(compModel | async)?.obj?.boolean}}">
You need to pipe the actual observable with async and then conditionally access it's future properties using the elvis operator to handle the case where they're not available yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With