Created
February 27, 2014 19:20
-
-
Save mwieher/9257159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.House = DS.Model.extend({ | |
doors: DS.hasMany('door'); | |
}); | |
App.Door = DS.Model.extend({ | |
index: DS.attr(); //this doors position in the list of Many doors | |
house: DS.belongsTo('house'); | |
}); | |
App.DoorController = Ember.ObjectController.extend({ | |
previous_door_id: function() { | |
var model = this.get('model'); | |
var index = model.get('index'); | |
var house = model.get('house'); | |
var doors = house.get('doors'); | |
var previous_door = doors[index-1]; | |
return previous_door.id; | |
}.property('id') | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment