What are the differences between Component and Directive?
In a short note, A component(@component) is a directive-with-a-template.
Some of the major differences are mentioned in a tabular form
Component | Directive |
---|---|
To register a component we use @Component meta-data annotation | To register directives we use @Directive meta-data annotation |
Components are typically used to create UI widgets | Directive is used to add behavior to an existing DOM element |
Component is used to break up the application into smaller components | Directive is use to design re-usable components |
Only one component can be present per DOM element | Many directives can be used per DOM element |
@View decorator or templateurl/template are mandatory | Directive doesn't use View |
February 26, 2022
1261
Read more
What is Angular Framework?
November 04, 2022
AngularWhat is a Angular module?
November 03, 2022
AngularWhat are the steps to use animation module?
October 31, 2022
Angular