What is the difference between directive and component in Angular 2?
Components | Directive | |
---|---|---|
1. | To register, use @Component meta-data annotation | To register, use @Directive meta-data annotation |
2. | Used to create UI widgets and break up app into smaller components | Use to design re-usable components and add behavior to existing DOM element. |
3. | Only one component allowed per DOM element | Many directives allowed per DOM element. |
4. | @View decorator is mandatory | Does not use View. |
Also Read: Angular 6 Question and Answers
BY Best Interview Question ON 02 Jul 2020