What is the difference between component and directive?

前端 未结 7 819
感动是毒
感动是毒 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:45

    Here is the actual definition.

    • If it has a template, it is a Component
    • else if it has a selector in brackets "[likethis]", it is an Attribute Directive
    • else it is a Structural Directive.

    Any other definition is wrong.

提交回复
热议问题