angularjs-ng-show

What is the difference between ng-if and ng-show/ng-hide

允我心安 提交于 2019-11-25 22:28:53
问题 I\'m trying to understand the difference between ng-if and ng-show / ng-hide , but they look the same to me. Is there a difference that I should keep in mind choosing to use one or the other? 回答1: ngIf The ngIf directive removes or recreates a portion of the DOM tree based on an expression. If the expression assigned to ngIf evaluates to a false value then the element is removed from the DOM, otherwise a clone of the element is reinserted into the DOM. <!-- when $scope.myValue is truthy