Troubles with modal functionality in Ionic application involving ion-slide-box

Utilizing ion-slider to display images has been a seamless experience, except for one hiccup. If I navigate directly from the first full image back to the home screen, the slider ceases to function properly.

To address this challenge, I have employed specific views and controllers in my setup.

Here is an example of the Home Template View:

        <ion-view view-title="Home">
          <ion-content>
            <div class="padding">
                <ion-slide-box>
                <ion-slide ng-repeat="Image in gallery" ng-click="showImages($index)" repeat-done="repeatDone()">
                      <img data-ng-src="{{sdcardpath}}{{Image.Path}}" width="100%"/>
                  <ion-slide>
                </ion-slide-box>
          </div>
          </ion-content>
          </ion-view>

Additionally, here is an overview of the Controller:

        .controller('HomeController', function($scope,$cordovaFile,$ionicBackdrop, $ionicModal, $ionicSlideBoxDelegate, $ionicScrollDelegate, $ionicPopup, $timeout) {
           $scope.sdcardpath = cordova.file.externalRootDirectory + foldername;
           $scope.gallery = [
            { Path: 'img1.png' },
            { Path: 'img2.png' },
            { Path: 'img3.png' },
          ];

           $scope.repeatDone = function() {
            $ionicSlideBoxDelegate.update();
          };

          /*
           * Show Full Screen Sliding Gallery Images
          */
          $scope.showImages = function(index) {
            $scope.activeSlide = index;
            $scope.showModal('templates/image-popover.html');
          };

          $scope.showModal = function(templateUrl) {
               $ionicModal.fromTemplateUrl(templateUrl, {
               scope: $scope
            }).then(function(modal) {
               $scope.modal = modal;
               $scope.modal.show();
            });
          };

          $scope.zoomMin = 1;
          $scope.updateSlideStatus = function(slide) {
           var zoomFactor = $ionicScrollDelegate.$getByHandle('scrollHandle' + slide).getScrollPosition().zoom;
           if (zoomFactor == $scope.zoomMin) {
               $timeout(function(){
                    $ionicSlideBoxDelegate.enableSlide(true); 
                  });
           } else {
               $timeout(function(){
                    $ionicSlideBoxDelegate.enableSlide(false); 
                });
           }
         };
        }

Furthermore, a glimpse of the Modal View - image-popover.html:

        <div class="modal image-modal">
          <ion-slide-box active-slide="activeSlide" show-pager="false">
            <ion-slide ng-repeat="Images in gallery">

              <ion-scroll direction="xy" locking="false" scrollbar-x="false" scrollbar-y="false"
              zooming="true" min-zoom="{{zoomMin}}" style="width: 100%; height: 100%"
              delegate-handle="scrollHandle{{$index}}" on-scroll="updateSlideStatus(activeSlide)" on-release="updateSlideStatus(activeSlide)">
               <img data-ng-src="{{sdcardpath}}{{Images.Path}}" width="100%"/>
            </ion-scroll>
          </ion-slide>
        </ion-slide-box>
        </div>

Lastly, there is a Directive included in the setup - repeatDone:

     .directive('repeatDone', function () {
       return function (scope, element, attrs) {
         if (scope.$last) { // all are rendered
           scope.$eval(attrs.repeatDone);
         }
       }

If you have any insights or solutions to resolve this issue, your input would be greatly appreciated!

Answer №1

I found the solution by making some adjustments in the Controller.

Controller

        .controller('HomeController', function($scope,$cordovaFile,$ionicBackdrop, $ionicModal, $ionicSlideBoxDelegate, $ionicScrollDelegate, $ionicPopup, $timeout) {
           $scope.sdcardpath = cordova.file.externalRootDirectory + foldername;
           $scope.gallery = [
            { Path: 'img1.png' },
            { Path: 'img2.png' },
            { Path: 'img3.png' },
          ];

           $scope.repeatDone = function() {
            $ionicSlideBoxDelegate.update();
          };

          /*
           * Display Full Screen Sliding Gallery Images
          */
          $scope.showImages = function(index) {
            $scope.activeSlide = index;
            $scope.showModal('templates/image-popover.html');
          };

          $scope.showModal = function(templateUrl) {
               $ionicModal.fromTemplateUrl(templateUrl, {
               scope: $scope
            }).then(function(modal) {
               $scope.modal = modal;
               $scope.modal.show();
            });
          };
            //Cleanup the modal when we're done with it!
        $scope.$on('$destroy', function() {
          $scope.modal.remove();
          $ionicSlideBoxDelegate.enableSlide(true);
          $ionicSlideBoxDelegate.update();
        });
        // Execute action on hide modal
        $scope.$on('modal.hidden', function() {
          // Execute action
            $ionicSlideBoxDelegate.enableSlide(true);
            $ionicSlideBoxDelegate.update();
        });
        // Execute action on remove modal
        $scope.$on('modal.removed', function() {
          // Execute action
            $ionicSlideBoxDelegate.enableSlide(true);
            $ionicSlideBoxDelegate.update();
        });

          $scope.zoomMin = 1;
          $scope.updateSlideStatus = function(slide) {
           var zoomFactor = $ionicScrollDelegate.$getByHandle('scrollHandle' + slide).getScrollPosition().zoom;
           if (zoomFactor == $scope.zoomMin) {
               $timeout(function(){
                    $ionicSlideBoxDelegate.enableSlide(true); 
                  });
           } else {
               $timeout(function(){
                    $ionicSlideBoxDelegate.enableSlide(false); 
                });
           }
         };
        }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the method for reverting style properties back to their CSS defaults using Javascript?

The php-generated page contains multiple elements structured like this: <td class="defaultTDStyle" style="color:userDefinedCustomColor" id="myTDId"></td> There is a default style in place with additional styles ap ...

Customizing the appearance of Indicators and Paginator in PrimeNG Carousel

I have integrated a carousel using PrimeNG which has the following design here Take note of the style of the carousel indicators and navigators. I want to achieve the default style of indicators/navigators for the carousel as shown here I have included t ...

Ensuring the presence of a bootstrap angular alert with protractor and cucumberJS

I am currently utilizing protractor, cucumberJS, and chai-as-promised for testing. There is a message (bootstrap alert of angularJS) that displays in the DOM when a specific button is clicked. This message disappears from the DOM after 6000 milliseconds. ...

What is the best way to extract raw data from a kendo dataSource?

After fetching data for my Kendo grid from the backend and populating it in the alignedProcessesToRiskGridOptions, I noticed that while the data is displayed in the grid, I also need access to the raw data for additional logic. Is there a way to retrieve d ...

Has anyone come across an XSLT that can effectively convert Apple Pages files into high-quality HTML?

When Apple’s word processor/DTP app Pages saves its files, it does so as zipped folders with an XML file containing the content and attachments like images stored as separate files. I am interested in converting this content into HTML format, using < ...

Updating the PHP form to include functionality for a reset button and adjusting the logic for

Having some difficulties with my PHP form. I created a simple form that consists of the following logic: if (isset($_POST['submit'])) { } elseif (isset($_POST['confirm'])) { } else { } The form includes a submit button, followed by a ...

Transforming the appearance of a compiled HTML component in AngularJS

UPDATING TEMPLATE VARIABLE ISSUE I have come across a problem where the value of the template variable is being lost. I'm not sure why this is happening yet, but I made some changes to the code: var template; $templateRequest("ng-templa ...

Utilizing jQuery's POST Method to Fetch JSON Data on a Website

I've developed a Java REST API and now I want to retrieve JSON data on my website (which is built using HTML & CSS) by utilizing jQuery. The method to be used is POST, and here is the structure of my JSON: { "sessionID" : "25574", "interactiv ...

Eliminate all elements marked with a particular class when the user clicks outside of a

I am currently building upon a project that I previously started here. Essentially, what I'm doing is dynamically generating tooltip popups that appear next to a link when it is clicked. However, I now need these tooltips to close when any click even ...

Prevent redundancy in fetching email and phone number through $http.get request

In my form, I have fields for name, email, and mobilenumber. I am able to post successfully to the server, but I want to ensure that each user can only use a unique combination of mobilenumber and email. I don't want duplicates in my database. var st ...

Learn the technique of swapping out a portion of a string with a value from an input field in real-time

My webpage has a form on the left side where users can input text, and on the right is some static text. I want the text on the right to update automatically as the user types in the input field on the left. In my HTML code, it looks something like this - ...

What is the best way to update objects in different scopes within AngularJS?

Exploring AngularJS for the first time, I find myself struggling with understanding scopes. My current dilemma involves modifying an object or variable from multiple scopes. Here's the scenario: I'm looking to centralize the user notification Co ...

Is it possible to create a grid by arranging each statement with a specific format?

After fetching and parsing some data, I have utilized the 'each' function to display it: $.ajax({ url : 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent('htt ...

Tips for saving HTML data locally

Is there a way to persist my HTML element tag data even after the user closes the browser? For example: <div class="classOne" data-random="50"> If I use jQuery to change the data attribute like this: $(".classOne").attr("data-random","40") How ca ...

Is there a way to showcase XML in a web browser while maintaining its whitespace and preserving its preformatted text?

In an attempt to simplify the process of formatting my reports, I am considering creating a basic XML language. This would resemble something like this: <?xml-stylesheet href="./report.css"?> <report> <title>A Tale of Two Cities</ ...

Ways to showcase information from an angular service

I'm struggling with displaying data from a service in my HTML view using AngularJS. My goal is to show a list of submitted forms called Occurrences in the view. When clicking on a list item, I want to be able to view all the data fields submitted thro ...

I need help picking out specific elements from this messy HTML code using XPath and lxml - any ideas on how to do

I am looking to extract specific strings from this HTML document using only lxml and clever XPath. The content of the strings may vary, but the structure of the surrounding HTML will remain constant. The strings I need are: 19/11/2010 AAAAAA/01 Normal U ...

Modifying the chart width in Chart.js: A step-by-step guide

After creating a chart using Chart Js, I encountered an issue where the chart did not fit within the specified width. Adjusting the attributes of canvas proved to be ineffective, specifically with regards to the width attribute. Despite changing the value, ...

Batch Script for Reading and Writing HTML files

My experience with writing DOS Batch scripts has been limited to basic tasks. However, I recently encountered a need to create a script that reads an HTML template file and generates a new file from it. I successfully managed to store the file data in a va ...

How can I use jQuery to show the text value of a selected checkbox, dropdown menu, and flipswitch in a popup?

This form's HTML is set up for input with a popup display feature upon submission. Currently, only text can be displayed in the popup. It doesn't show the text of selected checkboxes or dropdown lists - just numbers for the dropdown and "ON" for ...