I am trying to subscribe to a nested object, but it does not work. Here is my fiddle. below is also my code
var ViewModel = function () {
this.data = ko.observable();
var sample = {
id: 1,
details: {
name: "Johnny",
surname: "Boy",
othername: ""
}
};
this.data(sample);
//This does not work
// this.data().details().name.subscribe(function (val) {
//data().details().othername(val)
// });
};
ko.applyBindings(new ViewModel());
and here is my html
<div data-bind="with: data">
<p>Name:
<span data-bind="text: details.name"></span>
</p>
<p>Surname:
<input data-bind='value: details.surname' />
</p>
<p>Other:
<input data-bind='value: details.othername' />
</p>