In Ember 2.7 assume you have a Person class that has an Address model (just assume city:DS.attr() is the only attribute).
app/models/person.js
import DS from 'ember-data';
export default DS.Model.extend({
firstName: DS.attr(),
lastName: DS.attr(),
fullName: Ember.computed('firstName', 'lastName', function() {
return `${this.get('lastName')}, ${this.get('firstName')}`;
});
An Employee inherits from Person and adds a status field (like hired, retired, fired, etc.)
app/models/employee.js
import DS from 'ember-data';
import Person from '../models/person';
export default Person.extend({
status: DS.attr(),
statusCode: DS.attr(),
});
In a component that is displaying the Employees, like this:
app/templates/components/employee-list.hbs
<div>
<h2></h2>
<p>Home Base : [WHAT GOES HERE TO DISPLAY eg. person.address.city?]</p>
<p>Status : </p>
</div>
So how can I access the address of this Employee (ie. this 'Person')?
Aucun commentaire:
Enregistrer un commentaire