[英]data-bind text with dash in property name
How do I access a property in a binding with an invalid variable name. 如何使用无效的变量名访问绑定中的属性。 For example:
例如:
// {"customer-name": "Explosion Pills"}
<span data-bind="text: customer-name">
This will try to subtract name
from customer
. 这将尝试从
customer
减去name
。
The following does not work: 以下不起作用:
<span data-bind="text: 'customer-name'">
as it will literally print out "customer-name." 因为它会打印出“客户名称”。 How can I access this property in a binding?
如何在绑定中访问此属性?
You can use the following format: 您可以使用以下格式:
<span data-bind="text: $data['customer-name']"></span>
Here is working fiddle: http://jsfiddle.net/kqntA/ 这是工作小提琴: http : //jsfiddle.net/kqntA/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.