我是杜兰达尔的新手。我试图在 durandal 使用 mimosa skelton 提供的演示应用程序中添加一个新模块。
我按照此步骤创建了模块
当我运行<li>
与数据绑定关联的应用程序时,DOM 中没有填充。即,页面中不显示任何数据。
但是当我使用 console.log 在 myPage.js 中打印数据时,它会给出所需的输出。
我的模块 backend.js
define(function(require){
return {
getCustomers:function(){
//do some ajax and return a promise
return $.ajax({
url: 'http://graph.facebook.com/facebook?callback=?',
dataType: 'json',
}).promise();
}
};
});
我的 myPage.js
define(function (require) {
var backend = require('backend');
var ko = require('knockout');
return {
customer:ko.observableArray([]),
activate:function(){
var that = this;
return backend.getCustomers().then(function(result){
that.customer(result);
});
}
};
});
我的页面.html
<div>
<h2>FB Page Detail</h2>
<ul data-bind="foreach: customer">
<li data-bind="text: name"></li>
</ul>
</div>
获得的结果
{"about":"Facebook's mission is to give people the power to share and make the world more open and connected.","category":"Product/service","company_overview":"Newsroom: http://newsroom.fb.com\nInvestor Relations: http://investor.fb.com/","founded":"February 4, 2004","is_published":true,"talking_about_count":207120,"username":"facebook","website":"http://www.facebook.com/facebook","were_here_count":0,"id":"20531316728","name":"Facebook","link":"http://www.facebook.com/facebook","likes":96174118,"cover":{"cover_id":"10151496277356729","source":"http://sphotos-a.ak.fbcdn.net/hphotos-ak-ash2/s720x720/247388_10151496277356729_2043388331_n.jpg","offset_y":0,"offset_x":0}}
我做错什么了?如何解决这个问题?