以下のクラスで
this
innew SeatReservation("Steve", this.availableMeals[0]),
は inside を参照しています。正しいものを参照するseats
にはどうすればよいですかavailableMeals
行ってもいいnew SeatReservation("Steve", parent.this.availableMeals[0]),
// Overall viewmodel for this screen, along with initial state
function ReservationsViewModel() {
//var self = this;
// Non-editable catalog data - would come from the server
this.availableMeals = [
{ mealName: "Standard (sandwich)", price: 0 },
{ mealName: "Premium (lobster)", price: 34.95 },
{ mealName: "Ultimate (whole zebra)", price: 290 }
];
// Editable data
this.seats = ko.observableArray([
new SeatReservation("Steve", this.availableMeals[0]),
new SeatReservation("Bert", this.availableMeals[0])
]);
// Operations
this.addSeat = function() {
self.seats.push(new SeatReservation("", this.availableMeals[0]));
}
}