[英]ko.computed by not using values in Viewmodel od knockout
is it possible to us ko.computed by using values which are not observable in viewmodel. 我们是否可以使用在viewmodel中无法观察到的值进行ko.compute计算。
self.EnableSave = ko.computed(function () {
if ($('#PoolName').val().toString().trim().length > 0 && $('#Description').val().toString().trim().length > 0 && self.MatrixList().length > 0) {
return true;
}
else {
return false;
}
});
I don't see any reason you couldn't use non-observables in a computed. 我看不出您无法在计算中使用不可观察变量的任何原因。 However, only changes to observables would trigger the computed to fire.
但是,只有对可观察对象的更改才会触发计算对象触发。 In this case, the computed would only reevaluate when MatrixList changes.
在这种情况下,仅当MatrixList更改时,才会重新计算计算值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.