2013-04-29 91 views
1

我有以下HTML:淘汰賽的foreach不工作

<!-- ko.foreach: properties --> 
<span data-bind="text: $data.Name"></span> 
<span data-bind="text: $data.Age"></span> 
<!-- /ko --> 

而且此javascript:

function MyViewModel() { 
    var self = this; 
    self.properties = ko.observableArray([ 
     {Name: "John", Age: 32}, 
     {Name: "Steve", Age: 23} 
    ]); 
} 
ko.applyBindings(new MyViewModel()); 

這裏的的jsfiddle http://jsfiddle.net/cFB5B/

爲什麼沒有在foreach工作?

+0

什麼? – bwoebi 2013-04-29 15:15:42

回答

4

你必須在foreach聲明中的類型.得多:

相反

<!-- ko.foreach: properties --> 

應該差不多,包括lib放到小提琴

<!-- ko foreach: properties -->