Single Choice Easy

QWhat is the difference between ng-if and ng-show directives in AngularJS?

ID: #7753 AngularJS MCQ 168 views
Question Info
#7753Q ID
EasyDifficulty
AngularJS MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A There is no difference between ng-if and ng-show ✔ ✖
  • B ng-if removes the element from the DOM, while ng-show hides the element using CSS ✔ ✖
  • C ng-show removes the element from the DOM, while ng-if hides the element using CSS ✔ ✖
  • D ng-if and ng-show are used for different purposes and cannot be compared ✔ ✖
Correct Answer

Explanation

Answer: B) ng-if removes the element from the DOM, while ng-show hides the element using CSS

Explanation: The ng-if directive removes the element from the DOM when its condition is false, while the ng-show directive hides the element using CSS when its condition is false.

Share This Question

Challenge a friend or share with your study group.