Dynamic generate Actionsheet with view content


#1

Hi,
We want to be able to dynamically generate the Actionview with dynamic content. However, we face a problem where we can’t force actionsheet buttons,thanks

 $ionicActionSheet.show({
     titleText: 'Possible Action',
     buttons: [{
         text: 'Acknowledge selected alarm(s)'
     }, {
         text: 'Acknowledge all current alarm(s)'
     }, {
         text: 'Mask selected alarm(s)'
     }, {
         text: 'Mask all current alarm(s)'
     }],
     cancelText: 'Cancel',
     cancel: function () {
         console.log('CANCELLED');
     },
     buttonClicked: function (index) {
         console.log('BUTTON CLICKED', index);
         return true;
     }
 });


#2

hi guys , any ideas please :smiley:


#3

Hey there! So what you can do is have the buttons declared in your controller or from a service and then use that in your action sheet setup.


#4

You can do like this

var buttonsGroup = [];
for (var i = 0; i < buttons.length; i++) {
var text = {“text”:buttons[i].optionText,“id”:buttons[i].optionId};
buttonsGroup.push(text);
}
$ionicActionSheet.show({
buttons: buttonsGroup})


#5

thanks

it is working for me


#6

Can we add html code or view inside ionic actionsheet.To be clear,I need an google map search input field in action sheet.Seems to be stupid ,but is there any chance…