0

我有一个控制器,我在其中定义TakenSeatNumbers变量:

TravelClient.TourSeatsController = Ember.ObjectController.extend({
  selectSeat: function(seat) {
    var orderTransaction = TravelClient.store.transaction();
    var takenSeatNumber = orderTransaction.createRecord(TravelClient.TakenSeatNumber, {number: seat.get('id')});
  }
});

如何TakenSeatsNumberstour/seats模板访问?该模型TourTourSeatsController.


4

1 回答 1

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')})
    );
  }
});
于 2013-02-15T17:07:13.837 回答