As a newcomer to KO, I have been utilizing the following code in my HTML file to print a specific value:
<!-- ko foreach: { data: JSON.parse($parent.options), as: 'option' } -->
<!-- ko if: option.label === 'AAA' || option.label === 'BBB' -->
<dd class="values" data-bind="html: option.value"></dd>
<!-- /ko -->
<!-- /ko -->
This setup is functioning properly. However, I have a new requirement where I need to store all the values from the loop into a variable and output them after the loop just like we would do in PHP:
foreach($data as $key=> $index){
if($key==0)
$var = $index['value'];
else
$var .= ' '.$index['value'];
}
echo $var
I am looking for a way to achieve the same result within KO's HTML file using the above mentioned KO loop structure.