2014-01-29 73 views

回答

2

您应该使用with设置方面,这将允许访问儿童

<div data-bind="text: FirstName"></div> 

<div data-bind="with: Children"> 
    <div data-bind="text: LastName"></div> 
</div> 
+0

我知道它应该很简单。是的,它非常有用,非常感谢。 – dineshd87

+0

@ dineshd87不客气。如果这有帮助 - 随时接受答案;) –

+0

对不起!我没有声誉来标记你的答案是正确的。 – dineshd87

0

我可以推荐你签我约束力的公约库,其在配置库KO公约,并带走最头疼的问题与绑定和上下文,

对于示例

http://jsfiddle.net/KLXN5/1/

<div> 
<div data-name="FirstName"></div> 
<div data-name="Children.LastName"></div> 

</div> 

If you have more than one property you want to access its better todo 

<div> 
    <div data-name="Children"> 
     <div data-name="LastName"></div> 
    </div> 
</div> 

https://github.com/AndersMalmgren/Knockout.BindingConventions/wiki

+0

感谢您的建议。我会看看。 – dineshd87

0

如果从内部访问的人这个尝试这样的事情。

//To Access the current value 
var x = this.Children().LastName() 

//To edit the current value 
this.Children().LastName("Some new value")