What I want (pseudocode):
@Component({
selector: 'app-some-component',
....
})
export class SomeComponentComponent {
constructor() {
console.log(@COMPONENT.SELECTOR); // logs 'app-some-component'
}
....
}
Background:
I have a simple component:
@Component({
selector: 'app-some-component',
....
})
export class SomeComponentComponent { ....
Now inside this component, I want to create an unique identifier which should contain some the name of the component.
Example:
'app-some-component_' + UuidUtil.generateUUID();
obviously it would be nicer if I do this with:
SELECTOR + '_' + UuidUtil.generateUUID();
but then I have to declare the selector as variable outside and it I get problems because my IDE (Webstorm) teslls me unkown selector in the *.html template.
How can I achieve this.
@duplication The solution posted there is pretty hacky because requires element ref which is cast to lowercase. I hope now, after 2 years, there is a better way. Maybe also due to the further development in typescript.