What is the difference between component and directive?

前端 未结 7 836
感动是毒
感动是毒 2020-11-29 20:01

I have just started working with Angular 2.

I was wondering what are the differences between components and directives in Angular 2?

7条回答
  •  情书的邮戳
    2020-11-29 20:49

    Components have their own view (HTML and styles). Directives are just "behavior" added to existing elements and components.
    Component extends Directive.

    Because of that there can only be one component on a host element, but multiple directives.

    Structural directives are directives applied to