Issue
How can you hide one of the actionsheet buttons conditionally?
$scope.showActionsheet = function() {
$ionicActionSheet.show({
titleText: "<i>{{program.label}}</i>" ,
buttons: [
{ text: '<i class="icon ion-gear-a"></i> Configuration' }, // show this only if (ng-if="program.actions.configuration")
{ text: '<i class="icon ion-cube"></i> Administration' }, // show this only if (ng-if="program.actions.administration")
{ text: '<i class="icon ion-edit"></i> Edit' },
{ text: '<i class="icon ion-person-add"></i> Parrainage' },
{ text: '<i class="icon ion-person-stalker"></i> Filleuls' },
{ text: '<i class="icon ion-clipboard"></i> CGV' },
],
destructiveText: 'Delete',
cancelText: 'Cancel',
});
};
how can you use ng-if with action sheet ???
Solution
You can make button array using condition like this.
$scope.showActionsheet = function(is_edit_show)
{
var button_array = [
{ text: '<i class="icon ion-gear-a"></i> Configuration' },
{ text: '<i class="icon ion-cube"></i> Administration' },
{ text: '<i class="icon ion-person-add"></i> Parrainage' },
{ text: '<i class="icon ion-person-stalker"></i> Filleuls' },
{ text: '<i class="icon ion-clipboard"></i> CGV' },
];
if(is_edit_show) //is_edit_show is boolean if it is TRUE edit button pushed in action button array otherwise not
{
button_array.push({ text: '<i class="icon ion-edit"></i> Edit' });
}
$ionicActionSheet.show({
titleText: "<i>{{program.label}}</i>" ,
buttons: button_array,
destructiveText: 'Delete',
cancelText: 'Cancel',
});
};
}
Answered By - Paresh Gami
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.