'Is there a better way to access Angular's components private properties?

If you pass a component reference into a function you can access Component's properties through a private property called ɵcmp, for example:

myFunction(TestComponent);

export function myFunction (component) {
  console.log('this is the component selector', component.ɵcmp.selectors[0]);
  console.log('these are component inputs', component.ɵcmp.inputs)
}

Is there any better way to access those properties without accessing this "magic" private property?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source