const page = angular.element('#contact-history')
this.scrollContainer = page ? page.parent().parent().parent() : null
如何使用Angular 1
改进代码并避免多个parent()
DOM,我希望选择overlay-content
id:
<div id="overlay-content" class="overlay-content container-fluid ng-scope">
<h1><span translate="" translate-values="{ section: $ctrl.overlayTitle }" class="ng-scope">My Historie</span>
<ui-view class="ng-scope">
<contact-history contact="::$resolve.contact" class="ng-scope ng-isolate-scope">
<div class="row contact-history" id="contact-history">
</div>
</my-iad-contact-history>
</ui-view>
<div ui-view="overlay" class="overlay ng-scope"></div>
</div>
答案 0 :(得分:0)
解决方案:
this.scrollContainer = page ? angular.element(document).find('#overlay-content') : null