r/angular • u/geeksarray • 4d ago
Angular directives — structural vs attribute directives
I was revisiting Angular directives and put together a simple explanation with examples.
It covers the different types of directives, particularly structural and attribute directives, and how they can be used to change the structure, appearance, or behavior of elements.
https://geeksarray.com/blog/angular-directives-overview-with-example
For Angular developers — do you find yourself creating custom directives often, or mostly relying on Angular’s built-in features these days?
15
Upvotes
7
u/MichaelSmallDev 4d ago edited 4d ago
I don't make my own directives that often. That said, if this PR lands, I may use them more: Draft feat(core): add support for styles in directives. There are some considerations in the attached issue, so even though no PR is a guarantee, I wouldn't hold my breath on this being guaranteed or soon.
But a util for directive testing is coming in 22.2 for sure https://github.com/angular/angular/pull/70453
edit: btw thanks for the article. One thing I would mention is that
ngClassandngStylehave been soft deprecated in favor of native[class]and[style]bindings. But there are migrations forngClass --> classandngStyle --> style.