0

Is there a way to get the class or type of a model? For example if my model was a "todo" and if I wanted to get that information from the record itself like:

todo = this.get('model');
todo.class

OR would it possible to get it from the 'content' of a controller? I think model is just an alias for content but I could be wrong. I figured there has to be a simple way to do this but I can't find anything after much googling. Thanks in advance for the help.

2 Answers 2

1

the constructor is probably what you're looking for, it's located on the proto of the object

`todo.constructor`

http://emberjs.jsbin.com/OxIDiVU/871/edit

1
  • Thanks for the help. I can't seem to get the value. Is it something like this?: todo = @get('model'); todo.constructor
    – sturoid
    Jul 27, 2014 at 6:05
0

I got it working with the following:

type = @get('model').get('constructor.typeKey')

Thanks to kingpin2k for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.