fix(angular): add NavParams

This commit is contained in:
Manu Mtz.-Almeida
2018-04-09 19:09:36 +02:00
parent d98421461e
commit 22ebbce57f
3 changed files with 2879 additions and 6 deletions

View File

@ -0,0 +1,45 @@
/**
* @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
* import { NavParams } from '@ionic/angular';
*
* export class MyClass{
*
* constructor(navParams: NavParams){
* // userParams is an object we have in our nav-parameters
* navParams.get('userParams');
* }
*
* }
* ```
*/
export class NavParams {
constructor(public data: {[key: string]: any} = {}) {}
/**
* Get the value of a nav-parameter for the current view
*
* ```ts
* import { NavParams } from 'ionic-angular';
*
* export class MyClass{
* constructor(public navParams: NavParams){
* // userParams is an object we have in our nav-parameters
* this.navParams.get('userParams');
* }
* }
* ```
*
* @param {string} param Which param you want to look up
*/
get(param: string): any {
return this.data[param];
}
}