問題:
I understand that ng-show
and ng-hide
affect the class set on an element and that ng-if
controls whether an element is rendered as part of the DOM. 我知道ng-show
和ng-hide
會影響元素上設置的類,並且ng-if
控制元素是否呈現爲DOM的一部分。
Are there guidelines on choosing ng-if
over ng-show
/ ng-hide
or vice-versa? 是否有關於選擇ng-if
不是ng-show
/ ng-hide
或相反的指南?
解決方案:
參考一: https://stackoom.com/question/1TlCN參考二: When to favor ng-if vs. ng-show/ng-hide?