In the above figure we have these two elements, component and directive
Directive:- It have some logic but not contains the structure
Component:- It is an element that specifies directive element and have the list of other directive instances.Why directives are used in angular?
- use to change the appearance behavior or layout of Document Object Model(DOM)
- helps to extend HTML
It can be classified into 3 categories:-
- Used in main class.
- It possess the detail about how the component processed at run time.
- They are responsible for HTML layout.
- Changing the DOM structure by adding,removing or manipulate the elements.
- It starts with * symbol.
- ngIf Directive:-Use to add or remove the HTML element according to the expression.
- ngfor Directive:-Use to repeat a portion of HTML template.
- ngswitch Directive:-Allow to add or remove DOM element.
3.Attribute Directives:-
They are used to change the behavior of DOM element. *ngclass and *ngstyle are examples of attribute directive.
- ngclass Directive:-used to add or remove the css class from html element
- ngstyle Directive:-used to modify the style of html element and used to change the html element dynamically.
Comments
Post a Comment