2016-08-04 54 views
0

这是视图别名敲除控制不工作

<ul class="container-full" data-bind="foreach: { data: notificationDetail, as: 'notification' }"> 
      <li class="odd"> 
       <div class="table"> 
        <div class="table-cell"> 
         <p data-bind="text:notification.notificationTime"></p> 
         <span data-bind="text: notification.notificationSubject"></span> 
        </div> 
        <div class="table-cell width-60px text-center"> 
         <img src="/ebms/app/public/spa/styles/images/icon-remove.png" /> 
        </div> 
       </div> 
      </li> 
     </ul> 

初始化功能:

function initializeView(notificationList) { 
      var notificationDetails=new Array(); 
      if (notificationList) { 
       this.notification = notificationList.length; 
       for (var i = 0; i < notificationList.length; i++) { 
        var notification = notificationList[i]; 
        notificationDetails.push(notification); 
       } 
       this.notificationDetail = notificationDetails; 
      } 
     } 

this.notificationDetail = ko.observableArray([]);

this.notificationDetail:this.notificationDetail:数组[2] 0:对象 NoNotification: “05” NotificationSubject: “通知子线1” NotificationTime: “2016年5月14日下午9点”

+0

notification.notificationTime不返回数据 –

+0

你的标记看起来不错。问题是你的viewModel.Try调试它。我调试了 –

+0

notificationDetail显示数据为-this.notificationDetail:Array [2] -0:Object --- NoNotification:“05”NotificationSubject:“Notification sub line 1”NotificationTime:“2016年5月14日9:00PM” –

回答

0

对于你可能不需要在'别名'之上做什么,你可以直接绑定观察对象。