0
這是一個真正簡單的例子,我有一個數組一個基本的JavaScript對象,我使用淘汰賽映射,使陣列可觀測等淘汰賽印刷
但在我申請的時候我唯一的結合我得到未定義。
任何想法爲什麼?
HTML
<div data-bind="with: Data">
<div class="tab-pane active" id="studydirections">
<div data-bind="template: { name: studydirectionstemplate, foreach: studydirections }">
</div>
</div>
</div>
<script id="studydirectionstemplate" type="text/html">
<div> <span data-bind="text: Name"> </span> </div>
</script>
的JavaScript
var viewModel = {};
var data = {
studydirections: [{
RecId: 299,
ColtechCode: 75,
Name: "FARM",
Description: "FARMING"},
{
RecId: 306,
ColtechCode: 12,
Name: "BACC",
Description: "ACCOUNTING"},
{
RecId: 334,
ColtechCode: 11,
Name: "BMAN",
Description: "BUSINESS MANAGEMENT"
}
]};
viewModel.Data = ko.mapping.fromJS(data);
ko.applyBindings(viewModel);
結果是
undefinedundefinedundefined
這裏是一個小提琴的鏈接來說明問題
http://jsfiddle.net/armandvdwalt/3Q267/
謝謝,我開玩笑說我有時候,將標誌着大約8分鐘正確 – Armand