Most frameworks include some sort of binding implementation. Ember is no exception and has bindings that can be used with any object. The following recipes explain how to use them as well as one-way and two-way binding.
In this example, there is a teacher and student Ember object. Each has its own set of properties and they both have homeroom. We can share the homeroom by setting an alias for the teacher object.
Let's begin by creating a teacher and student
Ember.Object
:const Teacher = Ember.Object.extend({ homeroom: '', age: '', gradeTeaching: '' }); const Student = Ember.Object.extend({ homeroom: Ember.computed.alias('teacher.homeroom'), age: '', grade: '', teacher: null });
The student
homeroom
isEmber.computed.alias
, which will bind thehomeroom
property toteacher.homeroom
.Next, we'll instantiate the
teacher
andstudent
objects:const avery = Teacher.create({ age: '27', homeroom: '1075', gradeTeaching: 'sophmore' }); const joey...