我有以下代码片段
function Person() {
var id;
var name;
var loginName;
var email;
}
function Substitude() {
this.substitude = ko.observable(new Person());
this.subBegin = ko.observable(Date());
this.subEnd = ko.observable(Date());
}
function SampleSubstitude() {
var testing = ko.observable(new Substitude());
var tester = getPerson(88,"Alpha Tester","a.tester","a.tester@example.com");
testing.substitude = tester;
return ko.utils.unwrapObservable(testing);
}
function getPerson(id, name, login, email) {
var person = ko.observable(new Person());
person.id = id;
person.name = name;
person.loginName = login;
person.email = email;
return ko.utils.unwrapObservable(person);
}
这是我的视图模型:
function AbsenceRequestModel() {
this.delegations = ko.observableArray();
this.addsubstitudeclick = function () {
var raw = SampleSubstitude();
var obj = ko.utils.unwrapObservable(new raw());
this.delegations.push(obj);
}
};
不幸的是,推送到我的数组的所有值都是空的。谁能给我一个提示,这里有什么问题?