Javascript Durandal ko映射:映射的li未在DOM中渲染

Javascript Durandal ko映射:映射的li未在DOM中渲染,javascript,html,knockout.js,durandal,ko.observablearray,Javascript,Html,Knockout.js,Durandal,Ko.observablearray,我是杜兰达尔的新手。我试图在durandal使用mimosa skelton提供的演示应用程序中添加一个新模块 我按照中的步骤创建了模块 当我运行与数据绑定关联的应用程序时,DOM中没有填充该应用程序。即,页面中未显示任何数据 但是当我使用console.log在myPage.js中打印数据时,它提供了所需的输出 my module backend.js define(function(require){ return { getCustomers:function(){

我是杜兰达尔的新手。我试图在durandal使用mimosa skelton提供的演示应用程序中添加一个新模块

我按照中的步骤创建了模块

当我运行与数据绑定关联的应用程序时,DOM中没有填充该应用程序。即,页面中未显示任何数据

但是当我使用console.log在myPage.js中打印数据时,它提供了所需的输出

my module 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);
          });
        }
      };
});
myPage.html

<div>
  <h2>FB Page Detail</h2>
  <ul data-bind="foreach: customer">
    <li data-bind="text: name"></li>
  </ul>
</div>

我做错了什么?如何解决此问题?

不确定如何在此处应用绑定,您可能需要使用,因为您的模型在视图模型中设置为“客户属性”。

data bind=“html:customer.name”

我认为您的问题在于如何使用knockoutJS而不是durandal。。您正在将
对象
(单个对象)传递给您的
observableArray
。。而您应该传递对象数组或一个对象数组

我简单地复制了你的问题


请注意,不会显示任何结果,但是如果您将magic
[]
放在数据周围,使其成为单个对象的数组,您将看到
Facebook
显示的名称

您的响应在服务器上看起来如何?在
that.customer(结果)中结果是什么样子?
结果
是一个数组?对象{关于:“Facebook的使命是给人们分享的权力,让世界更加开放和互联。”,类别:“产品/服务”,公司概述:“新闻编辑室:↵投资者关系:“,成立于2004年2月4日”,是_出版的:真的…}你们这里的是对象而不是数组
{"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}}