UNPKG

4.98 kBTypeScriptView Raw
1import { App } from '../app/app';
2import { Config } from '../../config/config';
3import { Popover } from './popover';
4import { PopoverOptions } from './popover-options';
5import { DeepLinker } from '../../navigation/deep-linker';
6/**
7 * @name PopoverController
8 * @description
9 * A Popover is a dialog that appears on top of the current page.
10 * It can be used for anything, but generally it is used for overflow
11 * actions that don't fit in the navigation bar.
12 *
13 * ### Creating
14 * A popover can be created by calling the `create` method. The view
15 * to display in the popover should be passed as the first argument.
16 * Any data to pass to the popover view can optionally be passed in
17 * the second argument. Options for the popover can optionally be
18 * passed in the third argument. See the [create](#create) method
19 * below for all available options.
20 *
21 * ### Presenting
22 * To present a popover, call the `present` method on a PopoverController instance.
23 * In order to position the popover relative to the element clicked, a click event
24 * needs to be passed into the options of the the `present method. If the event
25 * is not passed, the popover will be positioned in the center of the current
26 * view. See the [usage](#usage) section for an example of passing this event.
27 *
28 * ### Dismissing
29 * To dismiss the popover after creation, call the `dismiss()` method on the
30 * `Popover` instance. The popover can also be dismissed from within the popover's
31 * view by calling the `dismiss()` method on the [ViewController](../../navigation/ViewController).
32 * The `dismiss()` call accepts an optional parameter that will be passed to the callback described
33 * as follows. The `onDidDismiss(<func>)` function can be called to set up a callback action that will
34 * be performed after the popover is dismissed, receiving the parameter passed to `dismiss()`.
35 * The popover will dismiss when the backdrop is clicked by implicitly performing `dismiss(null)`,
36 * but this can be disabled by setting `enableBackdropDismiss` to `false` in the popover options.
37 *
38 * > Note that after the component is dismissed, it will not be usable anymore and
39 * another one must be created. This can be avoided by wrapping the creation and
40 * presentation of the component in a reusable function as shown in the [usage](#usage)
41 * section below.
42 *
43 * @usage
44 *
45 * To open a popover on the click of a button, pass `$event` to the method
46 * which creates and presents the popover:
47 *
48 * ```html
49 * <button ion-button icon-only (click)="presentPopover($event)">
50 * <ion-icon name="more"></ion-icon>
51 * </button>
52 * ```
53 *
54 * ```ts
55 * import { PopoverController } from 'ionic-angular';
56 *
57 * @Component({})
58 * class MyPage {
59 * constructor(public popoverCtrl: PopoverController) {}
60 *
61 * presentPopover(myEvent) {
62 * let popover = this.popoverCtrl.create(PopoverPage);
63 * popover.present({
64 * ev: myEvent
65 * });
66 * }
67 * }
68 * ```
69 *
70 * The `PopoverPage` will display inside of the popover, and
71 * can be anything. Below is an example of a page with items
72 * that close the popover on click.
73 *
74 * ```ts
75 * @Component({
76 * template: `
77 * <ion-list>
78 * <ion-list-header>Ionic</ion-list-header>
79 * <button ion-item (click)="close()">Learn Ionic</button>
80 * <button ion-item (click)="close()">Documentation</button>
81 * <button ion-item (click)="close()">Showcase</button>
82 * <button ion-item (click)="close()">GitHub Repo</button>
83 * </ion-list>
84 * `
85 * })
86 * class PopoverPage {
87 * constructor(public viewCtrl: ViewController) {}
88 *
89 * close() {
90 * this.viewCtrl.dismiss();
91 * }
92 * }
93 * ```
94 * @advanced
95 * Popover Options
96 *
97 * | Option | Type | Description |
98 * |-----------------------|------------|------------------------------------------------------------------------------------------------------------------|
99 * | cssClass |`string` | Additional classes for custom styles, separated by spaces. |
100 * | showBackdrop |`boolean` | Whether to show the backdrop. Default true. |
101 * | enableBackdropDismiss |`boolean` | Whether the popover should be dismissed by tapping the backdrop. Default true. |
102 *
103 *
104 *
105 * @demo /docs/demos/src/popover/
106 */
107export declare class PopoverController {
108 private _app;
109 config: Config;
110 private _deepLinker;
111 constructor(_app: App, config: Config, _deepLinker: DeepLinker);
112 /**
113 * Present a popover. See below for options
114 * @param {object} component The Popover
115 * @param {object} data Any data to pass to the Popover view
116 * @param {PopoverOptions} opts Popover options
117 */
118 create(component: any, data?: {}, opts?: PopoverOptions): Popover;
119}