I've been using Knockoutjs for a while, but there is something I haven't been able to solve and I'm sure there must be an easy way to do it.
I really like nesting objects, using "foreach" on the html and then accessing each of these object's property directly. That way it keeps the code simple and clear.
The problem is that sometimes I use an observableArray to hold only one element in order to use the "foreach way" that I mention.
Is there other way of saying "I'm now within this scope", same behaviour as "foreach".
Example: here
<body>
<!-- ko foreach: people -->
<div data-bind="text: name">name</div>
<!-- /ko -->
<br />
<!-- here I would like to say I'm inside 'importantPerson' and therefore name is a property of importantPerson -->
<!-- <div data-bind="text: name">name (important)</div> -->
<br />
</body>
Aucun commentaire:
Enregistrer un commentaire