我有下面的代碼片段淘汰賽解開復雜的對象
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","[email protected]");
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);
}
};
不幸的是所有的值推到我的數組是空的。任何人都可以給我一個提示,這裏有什麼不對?
它是替代品,而不是替代品。這更像是一種語法的東西,但我不得不說出來。 – arkanciscan
@arkanciscan:這是更多*拼寫*的東西。與語法無關。 ;-) –