I am new to KO, in my html file I am printing a value like this -

<!-- 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 -->

And its working fine . But what I want is, I want assign all values of loop to a variable and want to print after loop. Like we do in php-

foreach($data as $key=> $index){
        $var = $index['value'];
        $var .= ' '.$index['value'];    

echo $var

Want to do the same in KO's html file using above KO loop.

Please help me in this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.