I try to use computed properties in other computed properties, and when I run the code, I get the following error in the console.
Cannot write ko.computed if you did not specify the "write" option
function AppViewModel() { var self = this; self.firstName = ko.observable('rahul'); self.lastName = ko.observable('sharma'); self.fullName = ko.computed(function() { return self.firstName() +' ' + self.lastName(); }); self.upperFullName = ko.computed(function() { return self.fullName.toUpperCase(); }); }
and here is the html code and js fiddle link
<p><input data-bind="value: firstName"></p> <p><input data-bind="value: lastName"></p> <p><input data-bind="value: fullName"></p> <p> <span data-bind="text: upperFullName"> </span> </p>
rahularyansharma
source share