Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!

Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Javascript

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 08-25-2018, 09:52 AM   #1
ajaxdns
Registered User
 
Join Date: Apr 2018
Posts: 1,360
Explain ngIf directive with an example.

The ngIf is a built-in template directive which is used to add or remove some parts of DOM. This addition or removal depends on the expression being true or false.

If the expression is evaluated to false, then the ngIf directive removes the HTML element. If the expression is evaluated to be true, then the element gets added to the DOM.

Syntax- *ngIf=”<condition>”

Example-



<ul *ngFor="let person of people"

*ngIf="person.age < 30">

<li>{{person.name}}</li></ul>
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
ajaxdns is offline   Reply With Quote

Old 09-20-2018, 10:31 PM   #2
richardmsmith
Registered User
 
Join Date: May 2018
Posts: 288
It is used to removes the HTML element if the expression evaluates to false.
If the if statement evaluates to true, a copy of the Element is added in the DOM.
syntax:<element ng-if="expression"></element>

Example:<input type="checkbox" ng-model="myVar" ng-init="myVar = true">
<div ng-if="myVar">
<h1>Welcome</h1>
<p>Welcome to my home.</p>
<hr>
</div>
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
richardmsmith is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Explain ngFor directive with an example. ajaxdns Javascript 0 08-25-2018 09:51 AM
Explain Directive scopes? ajaxdns Javascript 0 08-25-2018 09:20 AM
Explain ng-app directive designpluz Graphic Design 2 12-04-2017 02:23 AM
Explain ng-disabled Directive in AngularJS. designpluz Graphic Design 0 11-29-2017 08:07 PM
Explain ng-include, Click, and Repeat directive in AngularJS. designpluz Graphic Design 0 11-29-2017 08:07 PM


All times are GMT -7. The time now is 10:11 AM.


Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.