Reputation: 450
Is it possible to bind unexisting property in observable object? Because after I mapped it I don't see the result.
Upvotes: 0
Views: 1958
Reputation: 26730
I don't know a clean way, but you can do it like this:
<div data-bind="text: data().field1 ? data().field1() : ''"></div>
Now (for some reason, not quite sure why) you need to explicitly communicate that the value of the observable has changed and the view should be updated:
ko.mapping.fromJS(Data, {}, model.data);
model.data.valueHasMutated();
Upvotes: 3