2014-01-15 106 views
0
App.Friend = DS.Model.extend({ 
    fid: DS.attr("Number"), 
    name: DS.attr("String"), 
    bills: DS.hasMany("bill", {async: true}) 
}); 

App.Bill = DS.Model.extend({ 
    description: DS.attr("String"), 
    amount: DS.attr("Number"), 
    date: DS.attr("Date"), 
    friend: DS.belongsTo("friend") 
}); 

我在我的余烬应用程序中有上述两个模型。我有如下路线定义如下将数据推入余烬对象

App.Router.map(function(){ 
    this.resource("friends", function(){ 
      this.resource("friend", {path: ":id"}); 
    }); 
}); 

我需要添加账单给特定的朋友,当我在朋友详细视图。但我不能够得到那个特定型号的控制在我的FriendController

App.FriendController = Ember.ObjectController.extend({ 
    actions: { 
    addBill: function() { 
     debugger; 
    } 
    } 
}); 

我怎么能我的账单添加到特定的朋友在这种情况下

回答

0

我没有看到一个途径,是模型被抓取?

App.FriendController = Ember.ObjectController.extend({ 
    actions: { 
    addBill: function() { 
     var model = this.get('model'); 
     model.get('bills').then(function(bills){ 
     bills.pushObject(.....); //Push it here 
     }); 
    } 
    } 
}); 
+0

Thanks @ kingpin2k。我被this.get(“model”)返回的promise所困惑。 – Dhakchianandan