0
我使用這個代碼來觀看兒童身高的變化:ng-show | NG-隱藏:看元素高度
$scope.$watch(function() {
return element.children().height();
},
function (newHeight) {
if (newHeight) {
element.height(newHeight);
}
});
它工作得很好用ng-if
,但ng-show | ng-hide
不火的高度變化的事件。 當我使用ng-show | ng-hide
指令時,有什麼方法可以觀察高度嗎?
實施例:
<div class="form-slider">
<div ng-if="step === 1" class="animate">
<div ng-show="error">Error message</div>
Some content
</div>
<div ng-if="step === 2" class="animate">
<div ng-show="error">Error message</div>
Some content
</div>
</div>
我使用動畫來ng-if
秒之間切換,所以: .form-slider
具有position: relative
,而.animate
:position: absolute
。正如你可能知道的,在這種情況下,html不會計算出.form-slider
的高度,我必須使用JS來改變它的高度。
您可以加入HTML您如何使用'納克'if'&'ng-show' –
如何確定步驟和錯誤值? –
錯誤附加到窗體,如果窗體不值 - 顯示錯誤。當用戶點擊下一步時,「步驟」值發生變化。 – ReasonX7