Angular Ng-if Directive - W3Schools
AngularJS ng-if Directive ❮ AngularJS Reference
❮ AngularJS Reference ★ +1 Track your progress - it's free! Log in Sign Up
Example
Uncheck a checkbox to remove a section:
Keep HTML: <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> Try it Yourself »Definition and Usage
The ng-if directive 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.
The ng-if directive is different from the ng-hide, which hides the display of the element, where the ng-if directive completely removes the element from the DOM.
Syntax
<element ng-if="expression"></element>Supported by all HTML elements.
Parameter Values
Value | Description |
---|---|
expression | An expression that will completely remove the element if it returns false. If it returns true, a copy of the element will be inserted instead. |
Từ khóa » Ng-show Vs Ng-hide Vs Ng-if
-
Define Ng-if, Ng-show And Ng-hide - GeeksforGeeks
-
Angularjs - When To Favor Ng-if Vs. Ng-show/ng-hide? - Stack Overflow
-
Sự Khác Biệt Giữa Ng-if Và Ng-show / Ng-hide? - HelpEx
-
What Is The Difference Between Ng-show / Ng-hide And Ng-if Directives?
-
AngularJS Tutorial => Ng-if Vs Ng-show
-
Angular Performance: Ng-show Vs Ng-if
-
What Is The Difference Between Ng-if And Ng-show/ng-hide
-
What Is The Difference Between Ng-if And Ng-show/ng-hide AngularJS?
-
What Is The Equivalent Of Ng-show And Ng-hide In Angular 2+? - Telerik
-
What Is The Difference Between Ng-if And Ng-show/ng-hide - Intellipaat
-
Difference Between NgIf And Hidden Or Display:none In Angular
-
NgShow - AngularJS: API
-
NgHide - AngularJS API Docs
-
The Difference Between Ng-show Vs. Ng-if - DevelopIntelligence