mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 22:17:40 +08:00
chore(navigation): update NavController and NavPush types
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { Directive, HostListener, Input, Optional } from '@angular/core';
|
||||
|
||||
import { NavController } from '../../navigation/nav-controller';
|
||||
import { Page } from '../../navigation/nav-util';
|
||||
|
||||
/**
|
||||
* @name NavPush
|
||||
@ -49,12 +50,12 @@ import { NavController } from '../../navigation/nav-controller';
|
||||
export class NavPush {
|
||||
|
||||
/**
|
||||
* @input {Page} The Page to push onto the Nav.
|
||||
* @input {Page | string} The component class or deeplink name you want to push onto the navigation stack.
|
||||
*/
|
||||
@Input() navPush: any[]|string;
|
||||
@Input() navPush: Page | string;
|
||||
|
||||
/**
|
||||
* @input {any} Parameters to pass to the page.
|
||||
* @input {any} Any NavParams you want to pass along to the next view.
|
||||
*/
|
||||
@Input() navParams: {[k: string]: any};
|
||||
|
||||
|
@ -2,6 +2,7 @@ import { EventEmitter } from '@angular/core';
|
||||
|
||||
import { Config } from '../config/config';
|
||||
import { NavOptions } from './nav-util';
|
||||
import { Page } from './nav-util';
|
||||
import { ViewController } from './view-controller';
|
||||
|
||||
|
||||
@ -146,7 +147,7 @@ import { ViewController } from './view-controller';
|
||||
* [pop()](#pop) or [setRoot()](#setRoot)).
|
||||
*
|
||||
* ## Pushing a View
|
||||
* To push a new view on to the navigation stack, use the `push` method.
|
||||
* To push a new view onto the navigation stack, use the `push` method.
|
||||
* If the page has an [`<ion-navbar>`](../../navbar/Navbar/),
|
||||
* a back button will automatically be added to the pushed view.
|
||||
*
|
||||
@ -178,7 +179,7 @@ import { ViewController } from './view-controller';
|
||||
* }
|
||||
*
|
||||
* pushPage(){
|
||||
* // push another page on to the navigation stack
|
||||
* // push another page onto the navigation stack
|
||||
* // causing the nav controller to transition to the new page
|
||||
* // optional data can also be passed to the pushed page.
|
||||
* this.navCtrl.push(OtherPage, {
|
||||
@ -406,12 +407,12 @@ export abstract class NavController {
|
||||
* Push a new component onto the current navigation stack. Pass any aditional information
|
||||
* along as an object. This additional information is accessible through NavParams
|
||||
*
|
||||
* @param {Page} page The page component class you want to push on to the navigation stack
|
||||
* @param {object} [params={}] Any nav-params you want to pass along to the next view
|
||||
* @param {Page|string} page The component class or deeplink name you want to push onto the navigation stack.
|
||||
* @param {object} [params={}] Any NavParams you want to pass along to the next view.
|
||||
* @param {object} [opts={}] Nav options to go with this transition.
|
||||
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
|
||||
*/
|
||||
abstract push(page: any, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
abstract push(page: Page | string, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
|
||||
/**
|
||||
* Inserts a component into the nav stack at the specified index. This is useful if
|
||||
@ -419,12 +420,12 @@ export abstract class NavController {
|
||||
*
|
||||
*
|
||||
* @param {number} insertIndex The index where to insert the page.
|
||||
* @param {Page} page The component you want to insert into the nav stack.
|
||||
* @param {object} [params={}] Any nav-params you want to pass along to the next page.
|
||||
* @param {Page|string} page The component class or deeplink name you want to push onto the navigation stack.
|
||||
* @param {object} [params={}] Any NavParams you want to pass along to the next view.
|
||||
* @param {object} [opts={}] Nav options to go with this transition.
|
||||
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
|
||||
*/
|
||||
abstract insert(insertIndex: number, page: any, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
abstract insert(insertIndex: number, page: Page | string, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
|
||||
/**
|
||||
* Inserts an array of components into the nav stack at the specified index.
|
||||
@ -436,7 +437,7 @@ export abstract class NavController {
|
||||
* @param {object} [opts={}] Nav options to go with this transition.
|
||||
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
|
||||
*/
|
||||
abstract insertPages(insertIndex: number, insertPages: Array<{page: any, params?: any}>, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
abstract insertPages(insertIndex: number, insertPages: Array<{page: Page | string, params?: any}>, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
|
||||
/**
|
||||
* Call to navigate back from a current component. Similar to `push()`, you
|
||||
@ -465,12 +466,12 @@ export abstract class NavController {
|
||||
* been found in the stack. Nav params are only used by this method
|
||||
* when a new instance needs to be created.
|
||||
*
|
||||
* @param {any} page A page can be a ViewController instance or string.
|
||||
* @param {object} [params={}] Any nav-params to be used when a new view instance is created at the root.
|
||||
* @param {Page|string|ViewController} page The component class or deeplink name you want to push onto the navigation stack.
|
||||
* @param {object} [params={}] Any NavParams to be used when a new view instance is created at the root.
|
||||
* @param {object} [opts={}] Nav options to go with this transition.
|
||||
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
|
||||
*/
|
||||
abstract popTo(page: any, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
abstract popTo(page: Page | string | ViewController, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@ -501,12 +502,12 @@ export abstract class NavController {
|
||||
|
||||
/**
|
||||
* Set the root for the current navigation stack.
|
||||
* @param {Page|ViewController} page The name of the component you want to push on the navigation stack.
|
||||
* @param {object} [params={}] Any nav-params you want to pass along to the next view.
|
||||
* @param {Page|string|ViewController} page The name of the component you want to push on the navigation stack.
|
||||
* @param {object} [params={}] Any NavParams you want to pass along to the next view.
|
||||
* @param {object} [opts={}] Any options you want to use pass to transtion.
|
||||
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
|
||||
*/
|
||||
abstract setRoot(pageOrViewCtrl: any, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
abstract setRoot(pageOrViewCtrl: Page | string | ViewController, params?: any, opts?: NavOptions, done?: Function): Promise<any>;
|
||||
|
||||
/**
|
||||
* Set the views of the current navigation stack and navigate to the
|
||||
@ -518,7 +519,7 @@ export abstract class NavController {
|
||||
* @param {Object} [opts={}] Nav options to go with this transition.
|
||||
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
|
||||
*/
|
||||
abstract setPages(pages: {page: any, params?: any}[], opts?: NavOptions, done?: Function): Promise<any>;
|
||||
abstract setPages(pages: ({page: Page | string, params?: any} | ViewController)[], opts?: NavOptions, done?: Function): Promise<any>;
|
||||
|
||||
/**
|
||||
* @param {number} index The index of the page to get.
|
||||
|
@ -186,6 +186,10 @@ export interface NavOptions {
|
||||
isNavRoot?: boolean;
|
||||
}
|
||||
|
||||
export interface Page extends Function {
|
||||
new (...args: any[]): any;
|
||||
}
|
||||
|
||||
export interface TransitionResolveFn {
|
||||
(hasCompleted: boolean, requiresTransition: boolean, enteringName?: string, leavingName?: string, direction?: string): void;
|
||||
}
|
||||
|
Reference in New Issue
Block a user