Knockout JS选项绑定特殊符号

时间:2013-12-10 08:29:35

标签: html5 knockout.js knockout-2.0 knockout-mvc

我有阵列

self.CompareSignArray = ko.observableArray([“& gt”,“& le”]);

并选择选项

 <select data-bind="options:  $root.CompareSignArray,value: Sign" ></select>

但是在下拉列表中我看到了&amp; gt&amp; le,但我希望看到“&gt;”并且≤ 什么解决问题

2 个答案:

答案 0 :(得分:1)

只需将你的角色添加到数组中:

self.CompareSignArray = ko.observableArray([">", "≤"]);

见这里:http://jsfiddle.net/V4GvT/

<强> HTML

<select data-bind="options:  CompareSignArray" ></select>

<强> JS

function viewmodel()
{
    var self = this;
    self.CompareSignArray = ko.observableArray([">", "≤"]);
}
ko.applyBindings(new viewmodel());

答案 1 :(得分:0)

这是JS。使用常规字符,例如here

self.CompareSignArray = ko.observableArray([">", "<"]);