Directives
What are directives?
TypeScript classes to manipulate DOM elements
Operate on existing elements
Don't have a template
Angular provides several directives: ngStyle, ngClass, ngModel

Creating custom directives
ng generate directive highlight
or ng g d highlight
Directive Usage
<p appHighlight>This is highlighted text</p>
Directive User Events
If we wanted to highlight the text only when the user mouses over the element, then we would need to react to user events.
Passing Inputs to a Directive
<p appHighlight="red">This is highlighted text</p>
Summary
What are directives?
Creating custom directives
Handling user events
Passing inputs to directive
Last updated