@Directive({ selector: '[myHighlight]' })
The @Directive decorator requires a css selector in order to identify the HTML associated with this directive from the template
This is copied from the example on the official website. I have a question: Does the @Directive decorator need to find the myHighlight selector from all templates? If that's the case, isn't it very resource intensive? Generally speaking, shouldn’t you specify a template to look for?
The document is very clear:
It should be to find all the elements that match this selector in the current template, which is very resource-consuming as you think. In fact, it is no different from jquery's selector.