Directives?
Really?
Then what are components?
The most basic building blocks of Angular
@DcoustaWilson
Slide 7
Slide 7 text
Directives
Component Structural Attribute
(Self-contained
directives)
Directives with a
template
To change layout
*ngIf
*ngFor
Change appearance
or behavior
@DcoustaWilson
Slide 8
Slide 8 text
CUSTOM ATTRIBUTE DIRECTIVE
ng generate directive directive-name
@DcoustaWilson
Slide 9
Slide 9 text
Steps to create Custom Attribute directives
• Create Directive from the CLI
• Inject services ElementRef and Renderer
• Register inside the module
• Use your Directives
@DcoustaWilson
Slide 10
Slide 10 text
Host Element?
@DcoustaWilson
Slide 11
Slide 11 text
@HostListener()
@DcoustaWilson
Slide 12
Slide 12 text
@HostBinding()
@DcoustaWilson
Slide 13
Slide 13 text
Thank You!
PLAY AROUND WITH HOST BINDING & HOST LISTENER here on Stackblitz:
https://stackblitz.com/edit/ngindia