NgIf Directive - Angular (Tutorial #10)

preview_player
Показать описание
In this video we will learn about NgIf Directive in Angular in Angular applications

What is NgIfDirective ?
NgIf is a structural directive that is used to add or remove the elements from the DOM on the basis of expression. NgIf works with true and false. If expression return true it will display the template (add the node in the DOM) and if expression returns false it will remove the node from the DOM

Suppose we have a variable userLoggedIn that will hold boolean value either true or false. If user is loggedin it will return true and then we want to display different template and if user is not logged in we will display different template

Syntax *ngIf="expression"

In programming language , we use else with if.Same in angular we you want to display different template if condition return false we can use else here as well.

but for this we will use angular element called ng-template. ng-template is an angular template that is used to display template with strutural directive. ng-template never get display directly. If get display on the basis of conditions using template reference variable and template reference variable starts with #(pound) sign

If you liked my channel , subscribe to it and like my videos. For any queries ask you question in comment section

you can also connect with me @

Рекомендации по теме
Комментарии
Автор

Nisha, you are an excellent trainer with expertise in the subject. You explained such complex concepts/topics of angular effortlessly. I am a big fan of you. I watched your whole angular series and only one word, it is awesome. I have never seen such a detailed explanation of Angular Topics. You really made our life easy. Thank you so much and Hope you will continue to share your knowledge with strugglers.

abhisheksoni
Автор

How simply you understand everything. i am follow all your videos and prepare for my interviews.

basantijena
Автор

You are superb mam.. you explain each and every term that displayed on screen.. thank you so much.. it helped us alot.💜

canada_c_apture
Автор

Vivid explanation.. Wonderful! Thanks too!

sandeepkumarreddytadoori
Автор

your video is very useful for me thank you mam

sdmdurai
Автор

Could you make video on the API. and how to communicate with the database when we are geting data from user form.

lavisharma
Автор

Hello Nisha,

Good work. I liked the way you explain. It would be good if you can create a series of video for any actual real world e-commerce app in Angular 2 with ASP.NET MVC.
Thanks again.!!

rushabhpatel
Автор

what about attribute diretives... i think you are not covered...

vasanthapandiyanm
Автор

Can we use a ternary operator instead of an if/else statement in ngIf?

creativep
Автор

How to change dynamically true and false

Murtaza