What are host directives and when are they useful?

Angular directives, pipes and DI · Experienced

Model answer

The hostDirectives option in @Component or @Directive lets a component or directive apply other directives to its host element, and choose which of their inputs and outputs to expose. This is composition: you can combine small behaviours, such as a focus or tooltip directive, into a component without extending a base class.

It keeps behaviour reusable and avoids inheritance chains, and the consumer does not need to add the directives in the template.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions