Sunday, August 28, 2022

What is the difference between Components and Directives?

Demo URL

@Components

@Directives

For register component we use @Component

meta-data annotation.


For register directives we use @Directive meta-data annotation.


Component is a directive which use shadow

DOM to create encapsulate visual behavior

called components. Components are typically

used to create Ul widgets.


Directives are used to add behavior to an existing DOM element.

Component is used to break up the application into smaller components.


Directive is used to design reusable components.



Only one component can be present per DOM element.


Many directive can be used in a per DOM element



Component is used to define pipes

You can't define Pipes in a directive.



@View decorator or templateurl template are

mandatory in the component.


Directives don't have a View.


No comments:

Post a Comment

How to build an Express and Node.js app with Typescript

  In this tutorial, you will learn how to set up a Node.js and Express project with Typescript and live auto-reloading. Note that this metho...