简体   繁体   English

淘汰JS $ data绑定上下文

[英]Knockout JS $data binding context

When I pass the $data object that is the result of a foreach loop to a typescript function, I'm able to access the loop items. 当将作为foreach循环结果的$ data对象传递给Typescript函数时,我可以访问循环项。 When I pass a $data object from anything other than a foreach loop to a typescript function, I see function signatures and other properties and objects, but no data. 当我将$ data对象从foreach循环之外的任何其他内容传递给Typescript函数时,我看到函数签名以及其他属性和对象,但是没有数据。

What I want to do is access any response data from a page just like I can access data from a foreach loop. 我想要做的是从页面访问任何响应数据,就像我可以从foreach循环访问数据一样。 How can I do this? 我怎样才能做到这一点?

$data is the view model object in the current context. $ data是当前上下文中的视图模型对象。 Hence, within a loop it is the object in the the array your looping but outsite the loop it is not that object anymore. 因此,在循环中,循环中的对象是数组中的对象,但不在循环中的对象不再是该对象。 Refer to Knockout reference to get ideas and understand the different contexts. 请参阅淘汰赛参考以获取想法并了解不同的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM