2017-09-20 39 views
0
const page = angular.element('#contact-history') 
this.scrollContainer = page ? page.parent().parent().parent() : null 

如何改進代碼,並採用了棱角分明1角1 - 提高angular.element /多個父()

的DOM避免多次parent(),我想選擇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

你想要什麼元素? – Jerinaw

+0

@Jerinaw此加入 –

+0

'this.scrollContainer =頁面? page.parents( '#DIV覆蓋內容'):null'?嘗試這個 ?希望你擁有jQuery的包括 – Rahul

回答

0

解決方案:

this.scrollContainer = page ? angular.element(document).find('#overlay-content') : null