knockout - HTML href

前端 未结 2 2227
半阙折子戏
半阙折子戏 2021-02-18 20:52

I have a foreach loop that goes through an array (filesObservableArray). The array has a key/value with the key: URLPath. When I bind the array within the HTML, I would like to

相关标签:
2条回答
  • 2021-02-18 21:08

    Have you looked at possibly using the attr bindings.

    http://knockoutjs.com/documentation/attr-binding.html

    0 讨论(0)
  • 2021-02-18 21:13

    I am not sure what do you want to achive with the span in the href but with the attr binding you can set just fine the href (or any other) attribute:

    <tbody data-bind="foreach: $root.filesObservableArray">
       <tr id="tradeRow">
           <td><a data-bind="attr: { href: URLPath }">Open file</a></td>
       </tr>
    </tbody>
    
    0 讨论(0)
提交回复
热议问题