📜  角度指令与组件 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:36.297000             🧑  作者: Mango

代码示例1
Components ARE Directives. 
They are an extenison of directives with their own template and features.
They are used for different things. Main differences:

Components:
- Have their own shadow DOM (an encapsulated template).
- Only one component can be present per DOM element.
- Used represent the core behaviour of DOM element.

Directives:
- Used to add behavior to an existing DOM element.
- Used to design re-usable components.
- Many directives can be used per DOM element.