5

The internet wasn't too kind to me this time. This is all I could find. So:

I know it is possible to get the runtime generated unique Id of the corresponding component like so:

var globalId = component.getGlobalId();

But, is it possible to get the name of the component programmatically in JS? That is, if my component is called 'ProjectView.cmp', the method should return 'ProjectView'.

1 Answer 1

11

you can simply use getName() method.

it returns the component's code-compatible camelCase name, e.g. 'cProjectView'

so if you want to get name without your custom namespace:

var cmpName = component.getName(); 
cmpName = cmpName.substr(1);
//ProjectView

if you want to get name with namespace:

var cmpName = component.getType();
//c:ProjectView
1
  • 1
    Thanks for the aura framework documentation. Didn't even know something like that existed! Mar 21, 2018 at 23:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .