在下面的班级
this
in指的new 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]));
}
}