我已经在淘汰赛js.I中添加了新属性到映射对象中。我可以访问表中添加的属性。但是当我装一个目的是另一种观点认为它并没有显示增加的属性,但我可以在UI访问映射属性将属性添加到使用映射插件映射的ko模型
function Ticket(jsTicket){
var self = this;
ko.mapping.fromJS(jsTicket, {}, this);
this.company = "Gover";
this.formattedDate = moment(self.date(),"YYYY-MM-DDTHH:mm:ss").format("MM-DD HH:MM");
//This method call to another page, I could access js attribute in that UI but
// couldn't access manually added attributes,what would be the solution to this
this.getRunTicket = function(){
servicet.getTicket(self);
}
}
html页面
<div data-role="page" id="rticketDetailsPage" data-theme="b">
<div data-role="content" data-theme="b" data-position="fixed">
<!-- mapped attribute from JS -->
<p>NO : <span data-bind="text: ticketNumber()"></p>
<!-- Manually added attributes -->
<p>Date : <span data-bind="text: formattedDate()"></p>
<p>Company : <span data-bind="text: company()"></p>
</div>
</>
Data grid Model
function DataGrid(){
var self = this;
self.dataGrid = ko.observableArray();
self.addTicketToGrid = function(ticket){
self.dataGrid.push(ticket);
}
}
数据网格的HTML
<tbody data-bind="foreach : dataGrid">
<tr>
<td><span data-bind="text : number(),click: getTicket"></span></td>
<!-- formatted date is manually added attribute,displays in grid-->
<td><span data-bind="text : formattedDate()></span></td>
<td><span data-bind="text : operatorName()"></span></td>
</tr>
</tbody>
为什么我无法在该范围内手动添加添加的属性?
预先感谢您
谢谢,现在正在工作 – ExCode