Actionsheet - Handler not working the second time


#1

In my code I have an ActionSheet with a number of buttons add programmatically by using the following code:

let actionSheet = ActionSheet.create({
    title: 'Example',
});
this.neededButtons.forEach((nButton) => {
   var button = {
       text: nButton.text,
       handler: () => {
          console.log(nButton.name);
       }
   }
   actionSheet.addButton(button);
});
this.nav.present(actionSheet);

My problem is, that this code was working but after one of the last updates of ionic 2 it isn’t working at the moment. All buttons are shown, but if I choose one of them nothing happens. There isn’t even an error message inside the console.

Can you help me? How I can make my code to work again? Thanks in advance!

Update: It has nothing to do with the fact, that the buttons are added programmatically. Even if I add them fix, there’s the same problem. The handlers don’t work.


#2

Your code works for me, so the problem is elsewhere.


#3

Yes it’s right. But I have two actionsheet in my code. The first time the handlers are working correctly. They are calling the second actionsheet and then the handlers of the second one are not working. They aren’t showing any reaction anymore. Sorry I should have mentioned this earlier.

Could this be a bug of ionic 2? I’m sure that it was working, when I wrote this code about two or three month ago.