Loading topic
imports array. It shows how to declare a directive class and how its selector decides which elements the directive attaches to.3 min readHighlightDirective with the selector [appHighlight]. Declaring it does nothing on it3 min read@Directive and apply it through the imports array of a standalone component. It also assumes you have used inject() to get a dependency. Here you will learn the two tools a directive uses to change the element it sits on.3 min read@Directive and apply it through a component's imports array. It also assumes you know Angular property and event binding. Here you will make a directive react to events on its host element and update the host's properties.3 min readimports array, and basic property binding in templates. It builds on the HighlightDirective from earlier chapters and shows how to let the template configure it.3 min readimports array, and use event binding such as (click)="...". It builds on the earlier chapters about host listeners and inputs.3 min readimports array, and use signals. It also assumes you know template reference variables such as #box. By default a directive's members are invisible to the template. The exportAs option changes th2 min read@Directive, read its host with ElementRef, and use host bindings. Here you will give a directive access to services and make sure it leaves nothing behind when Angular destroys it.2 min read@Directive. It also assumes you know how signal input() and output() work, and you can read a component's imports array. If any of these are unfamiliar, review the earlier chapters on inputs and outputs first.2 min readhost metadata and a signal input, as in the earlier chapters. It also assumes you know basic describe/it/expect syntax from Jasmine or Jest. We test the HighlightDirective from the inputs chapter.2 min read@Directive with an attribute selector, the host metadata property, signal inputs and outputs, and inject(). The mistakes below are the ones that most often break directives in real applications.3 min read