-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): add popover interface as an option
- Loading branch information
1 parent
314f7e5
commit 745d808
Showing
8 changed files
with
212 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { NavParams } from '../../navigation/nav-params'; | ||
import { ViewController } from '../../navigation/view-controller'; | ||
|
||
/** @private */ | ||
export interface SelectPopoverOption { | ||
text: string; | ||
value: string; | ||
disabled: boolean; | ||
checked: boolean; | ||
} | ||
|
||
/** @private */ | ||
@Component({ | ||
template: ` | ||
<ion-list radio-group [(ngModel)]="value"> | ||
<ion-item *ngFor="let option of options; let i = index"> | ||
<ion-label>{{option.text}}</ion-label> | ||
<ion-radio [checked]="option.checked" [value]="option.value" [disabled]="option.disabled"></ion-radio> | ||
</ion-item> | ||
</ion-list> | ||
` | ||
}) | ||
export class SelectPopover implements OnInit { | ||
|
||
public get value() { | ||
let checkedOption = this.options.find(option => option.checked); | ||
|
||
return checkedOption ? checkedOption.value : undefined; | ||
} | ||
|
||
public set value(value: any) { | ||
this.viewController.dismiss(value); | ||
} | ||
|
||
private options: SelectPopoverOption[]; | ||
|
||
constructor( | ||
private navParams: NavParams, | ||
private viewController: ViewController | ||
) { } | ||
|
||
public ngOnInit() { | ||
this.options = this.navParams.data.options; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.