我有一个控制器,我在其中定义TakenSeatNumbers
变量:
TravelClient.TourSeatsController = Ember.ObjectController.extend({
selectSeat: function(seat) {
var orderTransaction = TravelClient.store.transaction();
var takenSeatNumber = orderTransaction.createRecord(TravelClient.TakenSeatNumber, {number: seat.get('id')});
}
});
如何从TakenSeatsNumbers
模板访问tour/seats
?模型Tour
位于TourSeatsController
。
答案 0 :(得分:1)
根据我的评论,将该函数变量(takenSeatsNumber
)提升为控制器内的属性,使其公开,类似于以下内容:
TravelClient.TourSeatsController = Ember.ObjectController.extend({
takenSeatNumber: null,
selectSeat: function(seat) {
var orderTransaction = TravelClient.store.transaction();
this.set('takenSeatNumber',
orderTransaction.createRecord(TravelClient.TakenSeatNumber, {number: seat.get('id')})
);
}
});