Calling a specific part of a function on an ionSlideDidChange Event

Right now I have a function which itself contains other functions, and then a for loop inside that function like so

function example(param1, param2){
  function first(){
    //manipulates params
  function second(){
    for(var i = 0; i < 5; i++){
      if (the slide is changed)
         //manipulate parameters somehow

Is there any way for me to right some sort of function like slides.on(ionSlideDidChange, //do something)? I know I can use (ionSlideDidChange)=“function()” in the html code but I specifically need to use this function inside the above nested function.

You can, I suppose, using some sort of artificial discriminator parameter, but this whole structure is bananas. Functions should be independent entities, and if there is some reason you can’t make first and second live on their own outside of example, I would back up and completely rethink the design.

Bananas? I would say spagetti :grinning:

Sorry jqx23:
Too much going in your thinking which is difficult to reengineer from my end

Maybe build an example in and share so we see the complete picture