FrontendDeveloper.in

Angular question detail

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

ComponentDirective
To register a component we use @Component meta-data annotationTo register a directive we use @Directive meta-data annotation
Components are typically used to create UI widgetsDirectives are used to add behavior to an existing DOM element
Component is used to break down the application into smaller componentsDirective is used to design re-usable components
Only one component can be present per DOM elementMany directives can be used per DOM element
@View decorator or templateurl/template are mandatoryDirective doesn't use View
Back to all Angular questions
Get LinkedIn Premium at Rs 399