mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 13:32:54 +08:00
docs(viewController, picker, popover, toast, gestures, utils): update docs
This commit is contained in:
@ -42,11 +42,40 @@ export class ViewController {
|
|||||||
private _cd: ChangeDetectorRef;
|
private _cd: ChangeDetectorRef;
|
||||||
protected _nav: NavController;
|
protected _nav: NavController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable to be subscribed to when the current component will become active
|
||||||
|
* @returns {Observable} Returns an observable
|
||||||
|
*/
|
||||||
willEnter: EventEmitter<any>;
|
willEnter: EventEmitter<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable to be subscribed to when the current component has become active
|
||||||
|
* @returns {Observable} Returns an observable
|
||||||
|
*/
|
||||||
didEnter: EventEmitter<any>;
|
didEnter: EventEmitter<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable to be subscribed to when the current component will no longer be active
|
||||||
|
* @returns {Observable} Returns an observable
|
||||||
|
*/
|
||||||
willLeave: EventEmitter<any>;
|
willLeave: EventEmitter<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable to be subscribed to when the current component is no long active
|
||||||
|
* @returns {Observable} Returns an observable
|
||||||
|
*/
|
||||||
didLeave: EventEmitter<any>;
|
didLeave: EventEmitter<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable to be subscribed to when the current component will be destroyed
|
||||||
|
* @returns {Observable} Returns an observable
|
||||||
|
*/
|
||||||
willUnload: EventEmitter<any>;
|
willUnload: EventEmitter<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable to be subscribed to when the current component has been destroyed
|
||||||
|
* @returns {Observable} Returns an observable
|
||||||
|
*/
|
||||||
didUnload: EventEmitter<any>;
|
didUnload: EventEmitter<any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,17 +255,7 @@ export class ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can find out the index of the current view is in the current navigation stack.
|
* Get the index of the current component in the current navigation stack.
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* export class Page1 {
|
|
||||||
* constructor(private view: ViewController){
|
|
||||||
* // Just log out the index
|
|
||||||
* console.log(this.view.index);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @returns {number} Returns the index of this page within its `NavController`.
|
* @returns {number} Returns the index of this page within its `NavController`.
|
||||||
*/
|
*/
|
||||||
get index(): number {
|
get index(): number {
|
||||||
@ -387,20 +406,10 @@ export class ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can find out of the current view has a Navbar or not. Be sure
|
*
|
||||||
|
* Find out if the current component has a NavBar or not. Be sure
|
||||||
* to wrap this in an `ionViewWillEnter` method in order to make sure
|
* to wrap this in an `ionViewWillEnter` method in order to make sure
|
||||||
* the view has rendered fully.
|
* the view has rendered fully.
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* export class Page1 {
|
|
||||||
* constructor(private viewCtrl: ViewController) {}
|
|
||||||
*
|
|
||||||
* ionViewWillEnter(){
|
|
||||||
* console.log('Do we have a Navbar?', this.viewCtrl.hasNavbar());
|
|
||||||
* }
|
|
||||||
*}
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @returns {boolean} Returns a boolean if this Page has a navbar or not.
|
* @returns {boolean} Returns a boolean if this Page has a navbar or not.
|
||||||
*/
|
*/
|
||||||
hasNavbar(): boolean {
|
hasNavbar(): boolean {
|
||||||
@ -456,19 +465,8 @@ export class ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can change the text of the back button on a view-by-view basis.
|
* Change the title of the back-button. Be sure to call this
|
||||||
*
|
* after `ionViewWillEnter` to make sure the DOM has been rendered.
|
||||||
* ```ts
|
|
||||||
* export class MyClass{
|
|
||||||
* constructor(private viewCtrl: ViewController) {}
|
|
||||||
*
|
|
||||||
* ionViewWillEnter() {
|
|
||||||
* this.viewCtrl.setBackButtonText('Previous');
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* Make sure you use the view events when calling this method, otherwise the back-button will not have been created
|
|
||||||
*
|
|
||||||
* @param {string} backButtonText Set the back button text.
|
* @param {string} backButtonText Set the back button text.
|
||||||
*/
|
*/
|
||||||
setBackButtonText(val: string) {
|
setBackButtonText(val: string) {
|
||||||
@ -479,7 +477,8 @@ export class ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the back button for the current view is visible or not. Be sure to wrap this in `ionViewWillEnter` to make sure the has been compleltly rendered.
|
* Set if the back button for the current view is visible or not. Be sure to call this
|
||||||
|
* after `ionViewWillEnter` to make sure the DOM has been rendered.
|
||||||
* @param {boolean} Set if this Page's back button should show or not.
|
* @param {boolean} Set if this Page's back button should show or not.
|
||||||
*/
|
*/
|
||||||
showBackButton(shouldShow: boolean) {
|
showBackButton(shouldShow: boolean) {
|
||||||
|
@ -93,6 +93,7 @@ export class Picker extends ViewController {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @name PickerController
|
* @name PickerController
|
||||||
* @description
|
* @description
|
||||||
*
|
*
|
||||||
@ -109,4 +110,4 @@ export class PickerController {
|
|||||||
return new Picker(this._app, opts);
|
return new Picker(this._app, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,15 @@ export class Popover extends ViewController {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
* @advanced
|
||||||
|
* Popover Options
|
||||||
|
*
|
||||||
|
* | Option | Type | Description |
|
||||||
|
* |-----------------------|------------|------------------------------------------------------------------------------------------------------------------|
|
||||||
|
* | cssClass |`string` | An additional class for custom styles. |
|
||||||
|
* | showBackdrop |`boolean` | Whether to show the backdrop. Default true. |
|
||||||
|
* | enableBackdropDismiss |`boolean` | Whether the popover should be dismissed by tapping the backdrop. Default true. |
|
||||||
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @demo /docs/v2/demos/popover/
|
* @demo /docs/v2/demos/popover/
|
||||||
@ -156,15 +165,7 @@ export class PopoverController {
|
|||||||
constructor(private _app: App) {}
|
constructor(private _app: App) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a popover with the following options
|
* Present a popover. See below for options
|
||||||
*
|
|
||||||
* | Option | Type | Description |
|
|
||||||
* |-----------------------|------------|------------------------------------------------------------------------------------------------------------------|
|
|
||||||
* | cssClass |`string` | An additional class for custom styles. |
|
|
||||||
* | showBackdrop |`boolean` | Whether to show the backdrop. Default true. |
|
|
||||||
* | enableBackdropDismiss |`boolean` | Whether the popover should be dismissed by tapping the backdrop. Default true. |
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param {object} componentType The Popover
|
* @param {object} componentType The Popover
|
||||||
* @param {object} data Any data to pass to the Popover view
|
* @param {object} data Any data to pass to the Popover view
|
||||||
* @param {PopoverOptions} opts Popover options
|
* @param {PopoverOptions} opts Popover options
|
||||||
|
@ -126,6 +126,16 @@ export class Toast extends ViewController {
|
|||||||
* toast.present();
|
* toast.present();
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
* @advanced
|
||||||
|
* | Property | Type | Default | Description |
|
||||||
|
* |-----------------------|-----------|-----------------|---------------------------------------------------------------------------------------------------------------|
|
||||||
|
* | message | `string` | - | The message for the toast. Long strings will wrap and the toast container will expand. |
|
||||||
|
* | duration | `number` | - | How many milliseconds to wait before hiding the toast. By default, it will show until `dismiss()` is called. |
|
||||||
|
* | position | `string` | "bottom" | The position of the toast on the screen. Accepted values: "top", "middle", "bottom". |
|
||||||
|
* | cssClass | `string` | - | Any additional class for custom styles. |
|
||||||
|
* | showCloseButton | `boolean` | false | Whether or not to show a button to close the toast. |
|
||||||
|
* | closeButtonText | `string` | "Close" | Text to display in the close button. |
|
||||||
|
* | dismissOnPageChange | `boolean` | false | Whether to dismiss the toast when navigating to a new page. |
|
||||||
*
|
*
|
||||||
* @demo /docs/v2/demos/toast/
|
* @demo /docs/v2/demos/toast/
|
||||||
*/
|
*/
|
||||||
@ -135,19 +145,7 @@ export class ToastController {
|
|||||||
constructor(private _app: App) {}
|
constructor(private _app: App) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Create a new toast component. See options below
|
||||||
* Toast options
|
|
||||||
*
|
|
||||||
* | Property | Type | Default | Description |
|
|
||||||
* |-----------------------|-----------|-----------------|---------------------------------------------------------------------------------------------------------------|
|
|
||||||
* | message | `string` | - | The message for the toast. Long strings will wrap and the toast container will expand. |
|
|
||||||
* | duration | `number` | - | How many milliseconds to wait before hiding the toast. By default, it will show until `dismiss()` is called. |
|
|
||||||
* | position | `string` | "bottom" | The position of the toast on the screen. Accepted values: "top", "middle", "bottom". |
|
|
||||||
* | cssClass | `string` | - | Any additional class for custom styles. |
|
|
||||||
* | showCloseButton | `boolean` | false | Whether or not to show a button to close the toast. |
|
|
||||||
* | closeButtonText | `string` | "Close" | Text to display in the close button. |
|
|
||||||
* | dismissOnPageChange | `boolean` | false | Whether to dismiss the toast when navigating to a new page. |
|
|
||||||
*
|
|
||||||
* @param {ToastOptions} opts Toast options. See the above table for available options.
|
* @param {ToastOptions} opts Toast options. See the above table for available options.
|
||||||
*/
|
*/
|
||||||
create(opts: ToastOptions = {}) {
|
create(opts: ToastOptions = {}) {
|
||||||
|
@ -2,7 +2,9 @@ import {SlideGesture} from './slide-gesture';
|
|||||||
import {defaults} from '../util/util';
|
import {defaults} from '../util/util';
|
||||||
import {windowDimensions} from '../util/dom';
|
import {windowDimensions} from '../util/dom';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
export class SlideEdgeGesture extends SlideGesture {
|
export class SlideEdgeGesture extends SlideGesture {
|
||||||
public edges: Array<string>;
|
public edges: Array<string>;
|
||||||
public maxEdgeStart: any;
|
public maxEdgeStart: any;
|
||||||
|
@ -2,6 +2,9 @@ import {DragGesture} from './drag-gesture';
|
|||||||
import {clamp} from '../util';
|
import {clamp} from '../util';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
export class SlideGesture extends DragGesture {
|
export class SlideGesture extends DragGesture {
|
||||||
public slide: SlideData = null;
|
public slide: SlideData = null;
|
||||||
|
|
||||||
|
@ -177,6 +177,9 @@ export function getQuerystring(url: string): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
export function reorderArray(array: any[], indexes: {from: number, to: number}): any[] {
|
export function reorderArray(array: any[], indexes: {from: number, to: number}): any[] {
|
||||||
let element = array[indexes.from];
|
let element = array[indexes.from];
|
||||||
array.splice(indexes.from, 1);
|
array.splice(indexes.from, 1);
|
||||||
|
Reference in New Issue
Block a user