Ionic-js-action-sheet
提供:Dev Guides
Ionic-JavaScriptアクションシート
- アクションシート*は、画面の下部にあるスライドアップペインをトリガーするIonicサービスで、さまざまな目的に使用できます。
アクションシートを使用する
次の例では、イオンアクションシートの使用方法を示します。 最初に $ ionicActionSheet サービスをコントローラーの依存関係として挿入し、次に* $ scope.showActionSheet()*関数を作成し、最後に作成した関数を呼び出すボタンをHTMLテンプレートに作成します。
コントローラコード
HTMLコード
コードの説明
ボタンをタップすると、 $ ionicActionSheet.show 関数がトリガーされ、アクションシートが表示されます。 オプションの1つがテープで録音されたときに呼び出される独自の関数を作成できます。 cancel 関数はペインを閉じますが、ペインを閉じる前にキャンセルオプションがタップされたときに呼び出される他の動作を追加できます。
- $ ionicActionSheet.show()*メソッドには、他にも便利なパラメーターがいくつかあります。 次の表でそれらすべてを確認できます。
メソッドオプションの表示
Properties | Type | Details |
---|---|---|
buttons | object | Creates button object with a text field. |
titleText | string | The title of the action sheet. |
cancelText | string | The text for cancel button. |
destructiveText | string | The text for a destructive button. |
cancel | function | Called when cancel button, backdrop or hardware back button is pressed. |
buttonClicked | function | Called 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. |
destructiveButtonClicked | function | Called when destructive button is clicked. Return true will close the action sheet. |
cancelOnStateChange | boolean | If true (default) it will cancel the action sheet when navigation state is changed. |