12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { Directive, HostListener, Optional } from '@angular/core';
  2. import { NavController } from '../../navigation/nav-controller';
  3. /**
  4. * @name NavPop
  5. * @description
  6. * Directive to declaratively pop the current page off from the
  7. * navigation stack.
  8. *
  9. * @usage
  10. * ```html
  11. * <ion-content>
  12. *
  13. * <button ion-button navPop>Go Back</button>
  14. *
  15. * </ion-content>
  16. * ```
  17. *
  18. * Similar to {@link /docs/api/components/nav/NavPush/ `NavPush` }
  19. * @demo /docs/demos/src/navigation/
  20. * @see {@link /docs/components#navigation Navigation Component Docs}
  21. * @see {@link ../NavPush NavPush API Docs}
  22. */
  23. var NavPop = (function () {
  24. function NavPop(_nav) {
  25. this._nav = _nav;
  26. if (!_nav) {
  27. console.error('navPop must be within a NavController');
  28. }
  29. }
  30. /**
  31. * @hidden
  32. */
  33. NavPop.prototype.onClick = function () {
  34. // If no target, or if target is _self, prevent default browser behavior
  35. if (this._nav) {
  36. this._nav.pop().catch(function () {
  37. (void 0) /* console.debug */;
  38. });
  39. return false;
  40. }
  41. return true;
  42. };
  43. NavPop.decorators = [
  44. { type: Directive, args: [{
  45. selector: '[navPop]'
  46. },] },
  47. ];
  48. /** @nocollapse */
  49. NavPop.ctorParameters = function () { return [
  50. { type: NavController, decorators: [{ type: Optional },] },
  51. ]; };
  52. NavPop.propDecorators = {
  53. 'onClick': [{ type: HostListener, args: ['click',] },],
  54. };
  55. return NavPop;
  56. }());
  57. export { NavPop };
  58. //# sourceMappingURL=nav-pop.js.map