绑定到简单的字符串数组 [英] Bind to simple array of strings
本文介绍了绑定到简单的字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我想将模板绑定到一个普通的旧字符串数组,我该在$ {??}表达式中放什么?
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:
<ul data-bind="template: { name: 'authorTemplate', foreach: authors }">
</ul>
作者只是["a", "b", "c"]
<script type="text/x-jquery-tmpl" id="authorTemplate">
<li>${what_do_I_put_here???}</li>
</script>
我尝试过:val
value
this
和this.toString()
.最后两个显示了[object Object],所以我怀疑我离那里很近.
I've tried: val
value
this
and this.toString()
. The last two displayed [object Object] so I suspect I'm pretty close there.
推荐答案
不使用模板时:
$data
这篇关于绑定到简单的字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文