Modal : Delegate for handle "xxx" could not find a corresponding element with delegate-handle

I want to use $ionicScrollDelegate.$getByHandle(‘xxx’).getScrollPosition().top within the Controller of a Modal window.

Whenever I use this command, following error appears :

ionic.bundle.js:26794 Delegate for handle “xxx” could not find a corresponding element with delegate-handle=“xxx”! getScrollPosition() was not called!
Possible cause: If you are calling getScrollPosition() immediately, and your element with delegate-handle=“xxx” is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to getScrollPosition() and try again.

Can anyone tell me how I can use $ionicScrollDelegate.$getByHandle within a modal window ?

What is the exact use case? Are you calling this method during initialization of your controller? Then try putting a $timeout around your call (as suggested by the error message).

Also keep in mind that $ionicScrollDelegate only works for ion-content and ion-scroll elements.

I have a ion-modal with an ion-scroll.

<ion-modal-view>
  <ion-content>
          <ion-scroll class="scroll-container" delegate-handle="xxx" on-scroll="checkScroll()">
....

Within the controller of this modal I want have function “checkScroll” which is activated whenver the user scrolls the ion-scroll. In this function I want to use :

$ionicScrollDelegate.$getByHandle(‘xxx’).getScrollPosition().top

Using timeout is not an option, since it needs to be executed directly when the user scrolls.

$timeout does not delay your call if you don’t want it to. But it does trigger the digest cycle. See this answer.

However, this does not seem to be the problem. I found this issue referring to your problem: $ionicScrollDelegate not working for ionic popups (ion-modal-view) · Issue #5897 · ionic-team/ionic-framework · GitHub

Check if this might solve your problem.

ok Thanks !

This works for me.