Bind to simple array of strings

后端 未结 2 818
北荒
北荒 2020-12-14 05:13

If I want to bind a template to a plain old array of strings, what do I put in the ${??} expression?

I hope this snippet isn\'t too short so as to confuse:



        
相关标签:
2条回答
  • 2020-12-14 06:10

    From the documentation, the answer is:

    When using a template: ${$data}

    When not using a template: $data

    0 讨论(0)
  • 2020-12-14 06:12

    For unnamed array (JSON like: ["value1", "value2"]), it would be:

    <ul data-bind="foreach: $root">
     <li data-bind="text: $data"></li>
    </ul>
    

    $root keyword does the trick.

    0 讨论(0)
提交回复
热议问题