@ionic/angular
Version:
Angular specific wrappers for @ionic/core
47 lines • 1.35 kB
JavaScript
/**
* @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 {
data;
constructor(data = {}) {
this.data = data;
console.warn(`[Ionic Warning]: NavParams has been deprecated in favor of using Angular's input API. Developers should migrate to either the @Input decorator or the Signals-based input API.`);
}
/**
* 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 param Which param you want to look up
*/
get(param) {
return this.data[param];
}
}
//# sourceMappingURL=nav-params.js.map