DS.Model.attributes

attributes{Ember.Map}static

Defined in addon/-private/system/model/attr.js:18

A map whose keys are the attributes of the model (properties described by DS.attr) and whose values are the meta object for the property.

Example

app/models/person.js
import DS from 'ember-data';

export default DS.Model.extend({
  firstName: attr('string'),
  lastName: attr('string'),
  birthday: attr('date')
});
import Ember from 'ember';
import Person from 'app/models/person';

var attributes = Ember.get(Person, 'attributes')

attributes.forEach(function(meta, name) {
  console.log(name, meta);
});

// prints:
// firstName {type: "string", isAttribute: true, options: Object, parentType: function, name: "firstName"}
// lastName {type: "string", isAttribute: true, options: Object, parentType: function, name: "lastName"}
// birthday {type: "date", isAttribute: true, options: Object, parentType: function, name: "birthday"}
doc_EmberJs
2016-11-30 16:50:15
Comments
Leave a Comment

Please login to continue.