If I have an observable array in my view model I can access individual items in that array using the item’s position within my script:
alert(this.travellers()[0].Age);
However, I cant seem to databind to the item/property using similar syntax in my view:
<label data-bind="text: travellers()[0].Age" />
Again, I’m sure I’m missing something fundamental.
Your syntax is correct, it just depends on where you are doing the binding to tell whether
travellersis available at that level.If you are inside of a template, then you would want to consider passing this value in via
templateOptionsor if your viewModel has global scope you could reference it liketext: yourViewModel.travellers()[0].Age.Sample with each option: http://jsfiddle.net/rniemeyer/brAtZ/