Front end of the Slack clone application.

nav-push.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { Directive, HostListener, Input, Optional } from '@angular/core';
  2. import { NavController } from '../../navigation/nav-controller';
  3. /**
  4. * @name NavPush
  5. * @description
  6. * Directive to declaratively push a new page to the current nav
  7. * stack.
  8. *
  9. * @usage
  10. * ```html
  11. * <button ion-button [navPush]="pushPage"></button>
  12. * ```
  13. *
  14. * To specify parameters you can use array syntax or the `navParams`
  15. * property:
  16. *
  17. * ```html
  18. * <button ion-button [navPush]="pushPage" [navParams]="params">Go</button>
  19. * ```
  20. *
  21. * Where `pushPage` and `params` are specified in your component,
  22. * and `pushPage` contains a reference to a
  23. * component you would like to push:
  24. *
  25. * ```ts
  26. * import { LoginPage } from './login';
  27. *
  28. * @Component({
  29. * template: `<button ion-button [navPush]="pushPage" [navParams]="params">Go</button>`
  30. * })
  31. * class MyPage {
  32. * pushPage: any;
  33. * params: Object;
  34. * constructor(){
  35. * this.pushPage = LoginPage;
  36. * this.params = { id: 42 };
  37. * }
  38. * }
  39. * ```
  40. *
  41. * @demo /docs/demos/src/navigation/
  42. * @see {@link /docs/components#navigation Navigation Component Docs}
  43. * @see {@link ../NavPop NavPop API Docs}
  44. *
  45. */
  46. export class NavPush {
  47. constructor(_nav) {
  48. this._nav = _nav;
  49. if (!_nav) {
  50. console.error('navPush must be within a NavController');
  51. }
  52. }
  53. /**
  54. * @hidden
  55. */
  56. onClick() {
  57. if (this._nav && this.navPush) {
  58. this._nav.push(this.navPush, this.navParams);
  59. return false;
  60. }
  61. return true;
  62. }
  63. }
  64. NavPush.decorators = [
  65. { type: Directive, args: [{
  66. selector: '[navPush]'
  67. },] },
  68. ];
  69. /** @nocollapse */
  70. NavPush.ctorParameters = () => [
  71. { type: NavController, decorators: [{ type: Optional },] },
  72. ];
  73. NavPush.propDecorators = {
  74. 'navPush': [{ type: Input },],
  75. 'navParams': [{ type: Input },],
  76. 'onClick': [{ type: HostListener, args: ['click',] },],
  77. };
  78. //# sourceMappingURL=nav-push.js.map