My application needs to have “interdependent” models. The loot model for example, requires access to the percentageCut and bankBalance properties in the merchant model.
I believe I’m doing this wrong somehow. From what I understand, models should not (and cannot) access the properties of a controller.
How should I structure my ember application in this case? Thanks!
App.IndexController = Ember.ObjectController.extend({
needs: ['merchant','loot']
});
App.MerchantController = Ember.ObjectController.extend();
App.Merchant = Ember.Object.extend({
bankBalance: '0',
percentageCut: '10'
});
App.LootController = Ember.ArrayController.extend({
needs: ['merchant']
});
# The code for lootAmountAfterMerchantCut does not work, and is merely to provide an idea of what i require.
App.Loot = Ember.Object.extend({
name: null,
bankBalanceChanged: null,
previousBankBalanceChanged: null,
lootAmountAfterMerchantCut: function(){
return (bankBalanceChanged - merchant.bankBalance) * (100-merchant.percentageCut) /100
}.property('merchant.percentageCut','merchant.bankBalance)
});