Custom attribute directives
Learn Custom attribute directives (Module 6 · Directives, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Creating custom attribute directives • Make your own directive when you want to reuse behaviour on many elements without a template. Example: a highlight directive that colours any element on hover. Create it with ng generate directive highlight . • The host element is the element carrying the directive (here the <p>). The selector in square brackets [appHighlight] means "match elements with this attribute".