What is the difference between component and directive?

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

    To complete what Günter said, we can distinguish two kinds of directives:

    • The structural ones that updates the DOM layout by adding or removing elements. The two common ones are NgFor and NgIf. These ones are linked to the template concept and must be prefixed by an *. See the section "Templates and *" in this link for more details: http://victorsavkin.com/post/119943127151/angular-2-template-syntax
    • The attribute ones that updates the behavior of the appearance of the element they are attached one.

    Hope it helps you, Thierry

    0 讨论(0)
提交回复
热议问题