I have an Ionic app with multiple angular controllers. One of the controllers is LoginCtrl, and the other is RegisterCtrl. The problem is that I call $ emit inside Login Ctrl to open the modal with the slider from RegisterCtrl:
HTML modal template
<ion-content class="register-wrapper">
<ion-slide-box delegate-handle="registerSlider" show-pager="false">
<ion-slide class="padding">
Slide 1
</ion-slide>
<ion-slide class="padding">
Slide 2
</ion-slide>
<ion-slide class="padding">
Slide 3
</ion-slide>
</ion-slide-box>
</ion-content>
LoginCrtl
$rootScope.$emit("showRegisterPopup", {data:'somedata'});
RegisterCrtl
$ionicModal.fromTemplateUrl('templates/modals/register-form1.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function (modal) {
$scope.modal = modal;
$scope.registerModalSlider = $ionicSlideBoxDelegate.$getByHandle('registerSlider');
$scope.registerModalSlider.enableSlide(false);
});
$rootScope.$on("showRegisterPopup", function(emitEvent, somedata){
if ($scope.registerModalSlider){
$timeout(function({
$scope.registerModalSlider.slide(2);
},200);
}
rc.showRegister();
});
The problem is that when I call the .slide () function of the slider, it is not sliding to the specified page, and I get the following error:
Delegate for handle "registerSlider" could not find a corresponding element with delegate-handle="registerSlider"! slide() was not called!
Possible cause: If you are calling slide() immediately, and your element with delegate-handle="registerSlider" is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to slide() and try again.
As you can see, I set the delegate descriptor in HTML, and I already have a .slide () call during the timeout, and this did not fix the problem.