ngSwitch Directive in Angular | Directives | Angular 12+

preview_player
Показать описание
In this lecture, you are going to learn about ngSwitch directive in angular and what is its use. ngSwitch is a structural directive like ngIf and ngFor and it adds or removes element from the webpage which satisfies a given expression assigned to ngSwitch.

We use ngSwitch like an attribute directive and along with ngSwitch we can use other two directives which is ngSwitchCase and ngDefault. We use ngSwichCase on different elements or components and we assign it with a value. The element for which the ngSwichCase value mathes the value assigned the ngSwich will be added in the DOM and other elements will be removed.

If none of the ngCaseValue matches in that case ngDefault element will be added in the DOM. Let's understand ngSwitch with an example.
Рекомендации по теме
Комментарии
Автор

Where is the custom direct for ngswitch?? We just explained ngswitch not custom direct! Pls do

RamKumar-floo