List the differences between Angular 2 components vs. directives.

devquora
devquora

Posted On: Feb 22, 2018

 

Apart from components, directives are also used in Angular 2 which allows us to attach behavior to elements in DOM. There are certain differences between the components and directives in Angular 2. They are:

  1. In Angular 2, a component is a directive with a view whereas a directive is a decorator with no view. Components are the specific type of directive that allows us to utilize web component functionality throughout our application. Whereas, Directive is the mechanism by which we attach behavior to elements.
  2. A component is used to break up the application into smaller components. Whereas, Directive is used to design the re-usable components.
  3. Components can be used to define pipes. Whereas, We cannot define pipes using directives.
  4. Components can be present per DOM element. Whereas, Directive is used to add behavior to an existing DOM element.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Angular 2 Interview Questions

    What is Angular 2 ?

    Angular 2 is a completely revived component-based framework in which an application is a tree of loosely coupled compon..

    Angular 2 Interview Questions

    List some advantages of Angular 2 over Angular1.

    Angular 2 is a re-written version of Angular1 and not an update. The best way to compare Angular 2 and Angular 1 is by f..

    Angular 2 Interview Questions

    What are the new features of Angular 2?

    Angular 2 is a platform that encompasses a wide range of capabilities. Some new features were added in Angular 2 which i..