nav-params.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (function (factory) {
  2. if (typeof module === "object" && typeof module.exports === "object") {
  3. var v = factory(require, exports);
  4. if (v !== undefined) module.exports = v;
  5. }
  6. else if (typeof define === "function" && define.amd) {
  7. define(["require", "exports"], factory);
  8. }
  9. })(function (require, exports) {
  10. "use strict";
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. /**
  13. * @name NavParams
  14. * @description
  15. * NavParams are an object that exists on a page and can contain data for that particular view.
  16. * Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
  17. * option with a simple `get` method.
  18. *
  19. * @usage
  20. * ```ts
  21. * import { NavParams } from 'ionic-angular';
  22. *
  23. * export class MyClass{
  24. *
  25. * constructor(navParams: NavParams){
  26. * // userParams is an object we have in our nav-parameters
  27. * navParams.get('userParams');
  28. * }
  29. *
  30. * }
  31. * ```
  32. * @demo /docs/demos/src/nav-params/
  33. * @see {@link /docs/components#navigation Navigation Component Docs}
  34. * @see {@link ../NavController/ NavController API Docs}
  35. * @see {@link /docs/api/components/nav/Nav/ Nav API Docs}
  36. * @see {@link /docs/api/components/nav/NavPush/ NavPush API Docs}
  37. */
  38. var NavParams = (function () {
  39. /**
  40. * @hidden
  41. * @param {TODO} data TODO
  42. */
  43. function NavParams(data) {
  44. if (data === void 0) { data = {}; }
  45. this.data = data;
  46. }
  47. /**
  48. * Get the value of a nav-parameter for the current view
  49. *
  50. * ```ts
  51. * import { NavParams } from 'ionic-angular';
  52. *
  53. * export class MyClass{
  54. * constructor(public navParams: NavParams){
  55. * // userParams is an object we have in our nav-parameters
  56. * this.navParams.get('userParams');
  57. * }
  58. * }
  59. * ```
  60. *
  61. *
  62. * @param {string} param Which param you want to look up
  63. */
  64. NavParams.prototype.get = function (param) {
  65. return this.data[param];
  66. };
  67. return NavParams;
  68. }());
  69. exports.NavParams = NavParams;
  70. });
  71. //# sourceMappingURL=nav-params.js.map