淘汰控制的别名不起作用

时间:2016-08-04 07:02:31

标签: html5 knockout.js

这是视图

<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:Array [2] 0:对象 NoNotification:&#34; 05&#34; NotificationSubject:&#34; Notification sub line 1&#34; 通知时间:&#34; 2016年5月14日下午9点及#34;

1 个答案:

答案 0 :(得分:0)

对于您在上面尝试做的事情&#39;别名&#39;可能不是必需的,你可以直接绑定observables。