From be4601319b5f4543c68409c4366ce32eba6008ee Mon Sep 17 00:00:00 2001 From: mhartington Date: Mon, 7 Dec 2015 10:43:11 -0500 Subject: [PATCH] docs(): nav-controller and view-controller --- ionic/components/nav/nav-controller.ts | 34 ++++++++++++++++++++++--- ionic/components/nav/view-controller.ts | 22 +++++++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index aba79056be..9a05e6bd47 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -1456,7 +1456,23 @@ let ctrlIds = -1; /** - * TODO + * @name NavParams + * @description + * NavParams are an object that exists on a page and can contain data for that particular view. + * Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible + * option with a simple `get` method. + * + * @usage + * ```ts + * export class MyClass{ + * constructor(params: NavParams){ + * this.params = params; + * // userParams is an object we have in our nav-parameters + * this.params.get('userParams'); + * } + * } + * ``` + * */ export class NavParams { /** @@ -1468,8 +1484,20 @@ export class NavParams { } /** - * TODO - * @param {string} Which param you want to look up + * Get the value of a nav-parameter for the current view + * + * ```ts + * export class MyClass{ + * constructor(params: NavParams){ + * this.params = params; + * // userParams is an object we have in our nav-parameters + * this.params.get('userParams'); + * } + * } + * ``` + * + * + * @param {string} parameter Which param you want to look up */ get(param) { return this.data[param]; diff --git a/ionic/components/nav/view-controller.ts b/ionic/components/nav/view-controller.ts index 4f1ecce5cb..0523adc001 100644 --- a/ionic/components/nav/view-controller.ts +++ b/ionic/components/nav/view-controller.ts @@ -189,14 +189,14 @@ export class ViewController { } /** - * You can find out of the current view has a Navbar or not. Be sure to wrap this in an `onPageLoaded` method in order to make sure the view has rendered fully. + * You can find out of the current view has a Navbar or not. Be sure to wrap this in an `onPageWillEnter` method in order to make sure the view has rendered fully. * * ```typescript * export class Page1 { * constructor(view: ViewController) { * this.view = view * } - * onPageLoaded(){ + * onPageWillEnter(){ * console.log('Do we have a Navbar?', this.view.hasNavbar()); * } *} @@ -257,7 +257,21 @@ export class ViewController { } /** - * @param {string} Set the back button text. + * You can change the text of the back button on a view-by-view basis. + * + * ```ts + * export class MyClass{ + * constructor(viewCtrl: ViewController){ + * this.viewCtrl = viewCtrl + * } + * onPageWillEnter() { + * 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. */ setBackButtonText(val) { let navbar = this.getNavbar(); @@ -267,7 +281,7 @@ export class ViewController { } /** - * Set if the back button for the current view is visible or not. Be sure to wrap this in `onPageLoaded` to make sure the has been compleltly rendered. + * Set if the back button for the current view is visible or not. Be sure to wrap this in `onPageWillEnter` to make sure the has been compleltly rendered. * @param {boolean} Set if this Page's back button should show or not. */ showBackButton(shouldShow) {