AngularJS ng-ifညွှန်ကြားချက်


ဥပမာ

အပိုင်းတစ်ခုကို ဖယ်ရှားရန် အမှတ်ခြစ်ရန်အကွက်ကို အမှန်ခြစ်ဖြုတ်ပါ-

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>

အဓိပ္ပါယ်နှင့် အသုံးပြုမှု

ng-ifစကားရပ်သည် မှားသည်ဟု အကဲဖြတ်ပါက HTML ဒြပ်စင်ကို ညွှန်ကြားချက်က ဖယ်ရှားသည်

if statement သည် true ဟု အကဲဖြတ်ပါက၊ Element ၏ မိတ္တူကို DOM တွင် ထည့်ထားသည်။

ng-ifng-if ညွှန်ကြားချက်သည် DOM မှဒြပ်စင်အား လုံးလုံးလျားလျားဖယ်ရှားသည့် ဒြပ်စင်၏ပြသမှုကို ဝှက်ထားသည့် ng-hide နှင့် ကွဲပြားသည်


အထားအသို

<element ng-if="expression"></element>

HTML ဒြပ်စင်များအားလုံးမှပံ့ပိုးထားသည်။


ကန့်သတ်တန်ဖိုးများ

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.