Receiving Type Error Cannot Read 'length' ionic.bundle.js


I have been struggling to find a big in my code that is causing this error :smile:
Receiving Type Error Cannot Read 'length' ionic.bundle.js

I have tracked it down to this piece of code - has anyone seen this before or know how to correct it? I expect its an issue with slidebox delegate however commenting this out does not make a difference and my template code is exactly the same as in other views that use a slidebox without issues?

$ionicModal.fromTemplateUrl('templates/exercise-modal.html', {
  scope: $scope
}).then(function (addExerciseModal) {
  $scope.addExerciseModal = addExerciseModal;

// Triggered in the exercise modal to close it
$scope.closeAddExerciseModal = function() {

// Open the exercise modal
$scope.OpenAddExerciseModal = function() {


maybe you have no slidebox with slides?

So the $ionicSlideBoxDelegate resturns undefined -> und the slide functions tries to figure out how many slides are there -> and it is trying to call undefined.length


Would that be the case even if I comment out this line!i still get the error…


could you poste the ionic version and the line number the error occured?


See the SO post

Many thanks


and you are sure that the controller is connected with a template where you are using ion-slide-box and ion-slides?

your template would be nice or a working code-pen


Ok, so this is my template code and when its all commented out I do not get the error.

<ion-slide-box class="exercise-slider-slides" does-continue="false" auto-play="true" show-pager="false">

  <ion-slide ng-repeat="image in activeExercise.images">

    <div class="modalSliderThumbnail" style="background-image:url({{image}}.jpg)"></div>


This is inside a modal that does not know the length of activeExercise.images upon loading the main page as I pass in that variable depending on the exercise loaded.

do you think that is what is happening? If so how can I assign it a value on page load to ensure its happy?


and so if $scope.activeExercise.images is not defined or empty -> you have an empty ion-slide-box.

i would add a ng-if to you ion-slide-box and only hang it into the dom, if you have slides :wink:


lol - that works :slight_smile:

Thanks for working through it with me!