Ionic-js-popup
Ionic-JavaScriptポップアップ
このサービスは、ユーザーとの対話に使用される通常のビューの上にポップアップウィンドウを作成するために使用されます。 4種類のポップアップがあります- show 、 confirm 、 alert 、 prompt 。
ポップアップを表示する
このポップアップはすべての中で最も複雑です。 ポップアップをトリガーするには、コントローラーに $ ionicPopup サービスを挿入し、使用するポップアップをトリガーするメソッド(この場合は* $ ionicPopup.show())を追加するだけです。 * onTap(e)*関数を使用して e.preventDefault()*メソッドを追加できます。これは、入力に変更が適用されていない場合にポップアップを開いたままにします。 ポップアップが閉じられると、約束されたオブジェクトは解決されます。
コントローラコード
HTMLコード
おそらく、上記の例でいくつかの新しいオプションが使用されていることに気づいたでしょう。 次の表では、これらのオプションとそのユースケースをすべて説明します。
ポップアップオプションを表示
Option | Type | Details |
---|---|---|
template | string | Inline HTML template of the popup. |
templateUrl | string | URL of the HTML template. |
title | string | The title of the popup. |
subTitle | string | The subtitle of the popup. |
cssClass | string | The CSS class name of the popup. |
scope | Scope | A scope of the popup. |
buttons | Array[Object] | Buttons that will be placed in footer of the popup. They can use their own properties and methods. text *is displayed on top of the button, type is the Ionic class used for the button, onTap* is function that will be triggered when the button is tapped. Returning a value will cause the promise to resolve with the given value. |
ポップアップの確認の使用
Confirm Popupは、Ionicポップアップのよりシンプルなバージョンです。 ユーザーには、キャンセルボタンとOKボタンを押して、対応する機能をトリガーできます。 いずれかのボタンが押されたときに解決される約束されたオブジェクトを返します。
コントローラコード
HTMLコード
次の表は、このポップアップに使用できるオプションを説明しています。
ポップアップオプションの確認
Option | Type | Details |
---|---|---|
template | string | Inline HTML template of the popup. |
templateUrl | string | URL of the HTML template. |
title | string | The title of the popup. |
subTitle | string | The subtitle of the popup. |
cssClass | string | The CSS class name of the popup. |
cancelText | string | The text for the Cancel button. |
cancelType | string | The Ionic button type of the Cancel button. |
okText | string | The text for the OK button. |
okType | string | The Ionic button type of the OK button. |
アラートポップアップの使用
アラートは、アラート情報をユーザーに表示するために使用される単純なポップアップです。 ポップアップを閉じて、ポップアップの約束されたオブジェクトを解決するために使用されるボタンは1つだけです。
コントローラコード
HTMLコード
それは次の画面を生成します-
次の表に、アラートポップアップに使用できるオプションを示します。
アラートポップアップオプション
Option | Type | Details |
---|---|---|
template | string | Inline HTML template of the popup. |
templateUrl | string | URL of the HTML template. |
title | string | The title of the popup. |
subTitle | string | The subtitle of the popup. |
cssClass | string | The CSS class name of the popup. |
okText | string | The text for the OK button. |
okType | string | The Ionic button type of the OK button. |
プロンプトポップアップの使用
Ionicを使用して作成できる最後のIonicポップアップは prompt です。 入力からの値でプロミスを解決する[OK]ボタンと、未定義の値で解決する[キャンセル]ボタンがあります。
コントローラコード
HTMLコード
それは次の画面を生成します-
次の表に、プロンプトポップアップに使用できるオプションを示します。
プロンプトポップアップオプション
Option | Type | Details |
---|---|---|
template | string | Inline HTML template of the popup. |
templateUrl | string | URL of the HTML template. |
title | string | The title of the popup. |
subTitle | string | The subtitle of the popup. |
cssClass | string | The CSS class name of the popup. |
inputType | string | The type for the input. |
inputPlaceholder | string | A placeholder for the input. |
cancelText | string | The text for the Cancel button. |
cancelType | string | The Ionic button type of the Cancel button. |
okText | string | The text for the OK button. |
okType | string | The Ionic button type of the OK button. |