03 April 2016

Ionic - Cara menggunakan Action Sheet

Ionic - Cara menggunakan Action Sheet
Sample Action Sheet

Action Sheet adalah layanan Ionic yang akan memicu geser panel di bagian bawah layar yang dapat Anda gunakan untuk berbagai keperluan.

Berikut Cara pemakainnya :

Tambahkan pada js
.controller('ActionSheetCtrl', function($scope, $ionicActionSheet) {
   $scope.triggerActionSheet = function() {
      // Show the action sheet
      var showActionSheet = $ionicActionSheet.show({
         buttons: [
            { text: 'Edit 1' },
            { text: 'Edit 2' }
         ],
   
         destructiveText: 'Delete',
         titleText: 'Action Sheet',
         cancelText: 'Cancel',
   
         cancel: function() {
            // add cancel code...
         },
   
         buttonClicked: function(index) {
            if(index === 0) {
               // add edit 1 code
            }
     
            if(index === 1) {
               // add edit 2 code
            }
         },
   
         destructiveButtonClicked: function() {
            // add delete code..
         }
      });
   };
})
Tambahkan pada view html Anda:
<button class = "button" ng-click="triggerActionSheet()">Action Sheet Button</button>
jangan lupa untuk menambahkan triggerActionSheet() untuk memanggil fungsi yang sudah kita buat diatas.

Show method options

PropertiesTypeDetails
buttonsobjectCreates button object with a text field.
titleTextstringThe title of the action sheet.
cancelTextstringThe text for cancel button.
destructiveTextstringThe text for a destructive button.
cancelfunctionCalled when cancel button, backdrop or hardware back button is pressed.
buttonClickedfunctionCalled when one of the buttons is tapped. Index is used for keeping track of which button is tapped. Return true will close the action sheet.
destructiveButtonClickedfunctionCalled when destructive button is clicked. Return true will close the action sheet.
cancelOnStateChangebooleanIf true (default) it will cancel the action sheet when navigation state is changed.

No comments: