检测observableArray中是否发生更改 [英] Detect if a change occur in observableArray

查看:83
本文介绍了检测observableArray中是否发生更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道吗,如果使用ko映射时是否可以检测到observableArray内部何时发生变化,这意味着不必手动创建模型?

Does anyone have idea, if it's possible to detect whenever a change occur inside observableArray while using ko mapping, this mean without having to create the model by hand?

self.items = ko.observableArray([])
var data = ko.mapping.fromJS(result)
self.items.push(data);

我想记录对象数组内任何属性中发生的任何更改.

I would like to log any changes occurred in any property inside my array of objects.

谢谢

推荐答案

如果我没记错的话,您应该可以在可观察对象上使用subscribe来获取该信息.

If I'm not mistaken, you should be able to use subscribe on the observable to get that information.

有关更多信息,请参见本页底部:

See the bottom of this page for more info:

明确订阅可观察对象

这篇关于检测observableArray中是否发生更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆