I recently picked KO and want to do something like the following.
Two inputs and they change each other.
HTML:
& lt; Input data-bind = "value: var1" type = "text" & gt; & Lt; Input Data-Bind- "Value: var2" type = "Text" & gt;
script:
function dataweet mode () {var self = this; Self.price = 5; Self.var1 = ko.observable (0); Self.var2 = ko.computed ({read: function () {if (self.var1 () & lt; = 0) {return 0;} Return (self.var1 - 1) / self.price;}, type: Function (value) {self () (1) (surrender) 1) * self. Prix; // value = 7.8, output is 44 for 1, // changes from var2 to 8.6 Desired to 40 for Virus 1 and for Var2 7.8.}, Owner: Self}); } Ko.applyBindings (New DataViewModel ());
When 40 is applied to var1, then var2 shows 7.8. But when 7.8 is changed to var2, the var1 update instead of 40 changes to 44 and var2 to 8.6.
I want to keep things done instead of reading the work of Var2.
This expression is incorrect
: Function (value) {Self.var1 ((value + 1) * self.price); },
Try updating this way
: function (value) {self.var1 ((value * self.price) + 1); },
No comments:
Post a Comment