select-popover-component.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { Component } from '@angular/core';
  2. import { NavParams } from '../../navigation/nav-params';
  3. import { ViewController } from '../../navigation/view-controller';
  4. /** @hidden */
  5. export class SelectPopover {
  6. constructor(navParams, viewController) {
  7. this.navParams = navParams;
  8. this.viewController = viewController;
  9. }
  10. get value() {
  11. let checkedOption = this.options.find(option => option.checked);
  12. return checkedOption ? checkedOption.value : undefined;
  13. }
  14. set value(value) {
  15. let checkedOption = this.options.find(option => option.value === value);
  16. if (checkedOption && checkedOption.handler) {
  17. checkedOption.handler();
  18. }
  19. this.viewController.dismiss(value);
  20. }
  21. ngOnInit() {
  22. this.options = this.navParams.data.options;
  23. }
  24. }
  25. SelectPopover.decorators = [
  26. { type: Component, args: [{
  27. template: `
  28. <ion-list radio-group [(ngModel)]="value">
  29. <ion-item *ngFor="let option of options">
  30. <ion-label>{{option.text}}</ion-label>
  31. <ion-radio [checked]="option.checked" [value]="option.value" [disabled]="option.disabled"></ion-radio>
  32. </ion-item>
  33. </ion-list>
  34. `
  35. },] },
  36. ];
  37. /** @nocollapse */
  38. SelectPopover.ctorParameters = () => [
  39. { type: NavParams, },
  40. { type: ViewController, },
  41. ];
  42. //# sourceMappingURL=select-popover-component.js.map