Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Ember component's name

Tags:

ember.js

If I call Ember.inspect(component), I get a response like:

<app@component:my-component::ember1246>

This suggests that the component is aware of its own name (my-component). Is there a way to access just that name?

like image 918
nullnullnull Avatar asked Mar 16 '23 02:03

nullnullnull


1 Answers

Ember.inspect() calls the objects toString() which in turn calls some internal ember metal functions to derive the name.

There is however an internal property which people have been using to get the name:

this.__proto__._debugContainerKey

This outputs component:my-component, then you can just split on :. There's an issue which will create a public way of exposing object meta information which we'll be able to use in the future: https://github.com/emberjs/ember.js/issues/10742

like image 147
Kit Sunde Avatar answered Mar 28 '23 07:03

Kit Sunde